Related question: Stop jQuery .data() from converting
According to the documentation for .data():
Every attempt is made to convert the string to a JavaScript value
(this includes booleans, numbers, objects, arrays, and null) otherwise
it is left as a string. To retrieve the value’s attribute as a string
without any attempt to convert it, use the attr() method
This is true for jQuery 1.7.2, but 1.8.2 does not do the conversion. Is this the new expected behavior?
For example, with the HTML <div data-code-name="007">Bond, James</div>
jQuery v1.7.2
$("div").data("codeName") returns 7
Example: http://jsfiddle.net/dMHS4/
jQuery v1.8.2
$("div").data("codeName") returns “007”
Example: http://jsfiddle.net/dMHS4/2/
I think this answers your question
http://bugs.jquery.com/ticket/7579
They also have a test fiddle http://jsfiddle.net/dmethvin/8SsWK/
And it shows that if converting to a number changed it from say 1.0 to 1, then it now is treated as a string, instead of a number. You can see this difference if you run there tests in 1.7.2 vs 1.8.2