diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2012-07-25 10:19:09 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-07-25 10:28:50 -0400 |
commit | ce15bd7d0c14106521bd21179b1507f2863d1960 (patch) | |
tree | ff32cd39f4c5d290e5d475592a02bf3982e3b07b /src | |
parent | da4d60929778490094fbf1f9c6abd9ea7d0e0c99 (diff) | |
download | jquery-ce15bd7d0c14106521bd21179b1507f2863d1960.tar.gz jquery-ce15bd7d0c14106521bd21179b1507f2863d1960.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/data.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/data.js b/src/data.js index c7de049a2..f51a3e520 100644 --- a/src/data.js +++ b/src/data.js @@ -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 ) {} |