File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -214,12 +214,12 @@ jQuery.extend( {
214214
215215 isNumeric : function ( obj ) {
216216
217- // As of jQuery 3.0, isNumeric is limited to
218- // strings and numbers (primitives or objects )
219- // that can be coerced to finite numbers (gh-2662)
220- var type = jQuery . type ( obj ) ;
221- return ( type === "number" || type === "string" ) &&
222- ( obj - parseFloat ( obj ) + 1 ) >= 0 ;
217+ // parseFloat NaNs numeric-cast false positives (null|true|false|"")
218+ // ...but misinterprets leading-number strings, particularly hex literals ("0x..." )
219+ // subtraction forces infinities to NaN
220+ // adding 1 corrects loss of precision from parseFloat (#15100)
221+ var realStringObj = obj && obj . toString ( ) ;
222+ return ! jQuery . isArray ( obj ) && ( realStringObj - parseFloat ( realStringObj ) + 1 ) >= 0 ;
223223 } ,
224224
225225 isPlainObject : function ( obj ) {
Original file line number Diff line number Diff line change @@ -455,8 +455,8 @@ QUnit.test( "isNumeric", function( assert ) {
455455 assert . ok ( t ( 1.5999999999999999 ) , "Very precise floating point number" ) ;
456456 assert . ok ( t ( 8e5 ) , "Exponential notation" ) ;
457457 assert . ok ( t ( "123e-2" ) , "Exponential notation string" ) ;
458+ assert . ok ( t ( new ToString ( "42" ) ) , "Custom .toString returning number" ) ;
458459
459- assert . equal ( t ( new ToString ( "42" ) ) , false , "Custom .toString returning number" ) ;
460460 assert . equal ( t ( "" ) , false , "Empty string" ) ;
461461 assert . equal ( t ( " " ) , false , "Whitespace characters string" ) ;
462462 assert . equal ( t ( "\t\t" ) , false , "Tab characters string" ) ;
You can’t perform that action at this time.
0 commit comments