Fix #7579. Don't convert to number if it changes the string. Close gh-852.

Net effect here is that hex numbers and most exponential-format numbers or long sequences of digits will remain strings rather than being coerced to numbers. `The people have spoken.
This commit is contained in:
Dave Methvin
2012-07-25 10:19:09 -04:00
parent da4d609297
commit ce15bd7d0c
2 changed files with 10 additions and 5 deletions

View File

@@ -304,8 +304,9 @@ function dataAttr( elem, key, data ) {
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
jQuery.isNumeric( data ) ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) :
// Only convert to a number if it doesn't change the string
+data + "" === data ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) :
data;
} catch( e ) {}