webshim icon indicating copy to clipboard operation
webshim copied to clipboard

Number stepper limits varies across browser

Open davidelrizzo opened this issue 10 years ago • 3 comments
trafficstars

Trying out the Number configurator with the following settings: <input min="1" max="1000" step="0.01" value="100" type="number" data-number='{"toFixed":2,"stepfactor":10000}' />

I get some very different results across browsers when the stepper hits the max and min limits:

  • Chrome 39: Value steps up to 1,000.00 then 1,099.99 then loops back to 101.00. At the lower end it goes from 1.00 to -98.99 and back again constantly.
  • Firefox 33: Never steps over 1,000.00 or below 1.00 (as you would expect)
  • Safari 6: Value only steps in multiples of 100 from 1 (eg. 101, 201, 301..), will never step above 901.

Any ideas why such a wide variance and why Chrome allows out of valid range steps?

davidelrizzo avatar Nov 27 '14 06:11 davidelrizzo

Sorry, for taking so long. Reason for this is that I'm using the native stepUp and stepDown methods. And it seems that Chrome has changed here something. Will look into this this weekend. I think it's a Chrome bug, but maybe they changed the spec again.

aFarkas avatar Dec 01 '14 10:12 aFarkas

If you use the native input and set the step attribute to 100 in Chrome it behaves like Safari. It doesn't ever exceed the max value or go below the min like the Webshim version seems to though.

davidelrizzo avatar Dec 01 '14 11:12 davidelrizzo

yeah but I mean the stepUp method:

document.querySelector('input[type="number"]').stepUp(1);

aFarkas avatar Dec 01 '14 13:12 aFarkas