j-ulrich / jquery-simulate-ext

jQuery simulate extended
https://j-ulrich.github.io/jquery-simulate-ext/
Other
146 stars 48 forks source link

Key-sequence throws error with <input type="email"> on Chrome #27

Open omahlama opened 9 years ago

omahlama commented 9 years ago

Test case (forked from demo):

http://jsfiddle.net/omahlama/5xLe3svo/1/

This throws an exception on chrome, the error is:

Failed to read the 'selectionStart' property from 'HTMLInputElement': 
The input element's type ('email') does not support selection.

Related stackoverflow question with the problem explained:

http://stackoverflow.com/questions/21177489/selectionstart-selectionend-on-input-type-number-no-longer-allowed-in-chrome

j-ulrich commented 9 years ago

Hm... I guess the only way to solve this issue is to either fix it in bililiteRange or replace bililiteRange.

Replacing bililiteRange gets more and more attractive. Rangy seems to be good candidate.

No! I was wrong! I could of course check the type of the element in in the key-sequence plugin and then prevent the creation of the range object. But then the question is: how should the simulation of the special sequences (like {leftarrow}, {backspace}, {selectall}, etc.) behave if we don't know where the cursor is? Should they just be ignored (i.e. no-ops)?

omahlama commented 9 years ago

I would guess that no-ops with browser detection would be the best option - it would be completely backwards compatible, as no-one was able to do those things with email inputs on chrome anyway.