mirror of
https://github.com/jquery/jquery.git
synced 2026-02-01 12:45:04 -05:00
Core: Improve isNumeric logic and test coverage
Also add back accidentally deleted comments about the implementation. Fixes gh-2780 Ref gh-2663 Ref gh-2781 Closes gh-2827
This commit is contained in:
committed by
Richard Gibson
parent
e04e246552
commit
7103d8ef47
@@ -217,7 +217,11 @@ jQuery.extend( {
|
||||
// that can be coerced to finite numbers (gh-2662)
|
||||
var type = jQuery.type( obj );
|
||||
return ( type === "number" || type === "string" ) &&
|
||||
( obj - parseFloat( obj ) + 1 ) >= 0;
|
||||
|
||||
// parseFloat NaNs numeric-cast false positives ("")
|
||||
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
|
||||
// subtraction forces infinities to NaN
|
||||
!isNaN( obj - parseFloat( obj ) );
|
||||
},
|
||||
|
||||
isPlainObject: function( obj ) {
|
||||
|
||||
Reference in New Issue
Block a user