Ticket #10856 (closed enhancement: duplicate)
jQuery.isNumeric() returns true for 32+bit integers, results in problem with .data() casting
|Reported by:||oemebamo||Owned by:|
When reading a data-attribute from an element that contains a numeric string bigger then 32bits, jQuery returns a wrongly casted value.
<div id="test" data-key="138718128824791043"></div>
If you fetch "$('#test').data('key')" for this element it returns "138718128824791040", which is a different number.
The cause is jQuery.isNumeric() returning true for "138718128824791043", and then .data() doing a parseFloat() for numeric attributes, while the specs for parseInt() and parseFloat() specify it's only safe for 32 bit integers/floats ( http://es5.github.com/x15.1.html#x220.127.116.11).
Test case: http://jsfiddle.net/oemebamo/ZdNRK/
Maybe jQuery.isNumeric() shouldn't only check if every character is a digit, but also if the length is safe to cast.
- Priority changed from undecided to low
- Status changed from new to open
- Type changed from bug to enhancement
- Status changed from open to closed
- Resolution set to duplicate