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 @@ -217,12 +217,12 @@ jQuery.extend( {
217217
218218 isNumeric : function ( obj ) {
219219
220- // parseFloat NaNs numeric-cast false positives (null|true|false|"")
221- // ...but misinterprets leading-number strings, particularly hex literals ("0x..." )
222- // subtraction forces infinities to NaN
223- // adding 1 corrects loss of precision from parseFloat (#15100)
224- var realStringObj = obj && obj . toString ( ) ;
225- return ! jQuery . isArray ( obj ) && ( realStringObj - parseFloat ( realStringObj ) + 1 ) >= 0 ;
220+ // As of jQuery 3.0, isNumeric is limited to
221+ // strings and numbers (primitives or objects )
222+ // that can be coerced to finite numbers (gh-2662)
223+ var type = jQuery . type ( obj ) ;
224+ return ( type === "number" || type === "string" ) &&
225+ ( obj - parseFloat ( obj ) + 1 ) >= 0 ;
226226 } ,
227227
228228 isEmptyObject : function ( obj ) {
Original file line number Diff line number Diff line change @@ -479,8 +479,8 @@ QUnit.test( "isNumeric", function( assert ) {
479479 assert . ok ( t ( 1.5999999999999999 ) , "Very precise floating point number" ) ;
480480 assert . ok ( t ( 8e5 ) , "Exponential notation" ) ;
481481 assert . ok ( t ( "123e-2" ) , "Exponential notation string" ) ;
482- assert . ok ( t ( new ToString ( "42" ) ) , "Custom .toString returning number" ) ;
483482
483+ assert . equal ( t ( new ToString ( "42" ) ) , false , "Custom .toString returning number" ) ;
484484 assert . equal ( t ( "" ) , false , "Empty string" ) ;
485485 assert . equal ( t ( " " ) , false , "Whitespace characters string" ) ;
486486 assert . equal ( t ( "\t\t" ) , false , "Tab characters string" ) ;
You can’t perform that action at this time.
0 commit comments