mirror of
https://github.com/jquery/jquery.git
synced 2026-02-07 02:04:55 -05:00
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:
@@ -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 ) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user