fix issue with saving input selection

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