vitalets / x-editable

In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
http://vitalets.github.io/x-editable
MIT License
6.51k stars 1.72k forks source link

[Bug] When input type is 'number', elem.setSelectionRange results in error. #1052

Closed mdeweerd closed 6 years ago

mdeweerd commented 7 years ago

Hi I've set the input type to 'number' but then I got VM1751:1 Uncaught DOMException: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('number') does not support selection. at eval (eval at setCursorPosition (http://localhost/locbox/assets/344a78e8/js/jqueryui-editable.js?oosk4t:25:1222),

Basically for this piece of code:

setCursorPosition: function(elem, pos) {
       if (elem.setSelectionRange) {
            elem.setSelectionRange(pos, pos);
       } ,

The function 'setSelectionRange' exists on the element, but it is not supported by the element type.

mdeweerd commented 7 years ago

I tried to reproduce it in a fiddle, but I get another error:

http://jsfiddle.net/le_top/2aus4en9/

The reference fiddle already has the same issue: http://jsfiddle.net/xBB5x/2511/

Mr-Newlove commented 6 years ago

I started getting this same error last night, seemingly out of nowhere. Is this something that could have been introduced in a very recent update?

mdeweerd commented 6 years ago

Closing request that is open since almost 1 year to relieve the team. Can live with - does not happen very often.

jcairney commented 5 years ago

This is still an issue and should be reopened.

Mr-Newlove commented 5 years ago

@jcairney I have got this error quite a few times, every single time it has actually originated from another error on the page. I was trying to reproduce the error to give an example but I was unable to. Try creating an empty HTML page with only the minimum required libraries and see if you still get the error. If you do please post it here so we can have a test case for the error.