assert that focused element is a Text input before saving selection

the current focused element may not be a text input. When this case occurs, calling selectionStart on it will throw an exception.
the following pull request assert that current active element is a text element before saving selection.