mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Ref #14313: NaN detection. Close gh-1352.
This commit is contained in:
parent
3a552cdfa7
commit
0bc0a69026
@ -224,7 +224,10 @@ jQuery.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
isNumeric: function( obj ) {
|
isNumeric: function( obj ) {
|
||||||
return !isNaN( parseFloat(obj) ) && isFinite( obj );
|
// parseFloat NaNs numeric-cast false positives (null|true|false|"")
|
||||||
|
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
|
||||||
|
// subtraction forces infinities to NaN
|
||||||
|
return obj - parseFloat( obj ) >= 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
isEmptyObject: function( obj ) {
|
isEmptyObject: function( obj ) {
|
||||||
@ -426,7 +429,7 @@ jQuery.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Support: IE<9
|
// Support: IE<9
|
||||||
// Workaround non-numeric length overrides of otherwise arraylike objects (e.g., NodeLists)
|
// Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
|
||||||
if ( len !== len ) {
|
if ( len !== len ) {
|
||||||
while ( second[j] !== undefined ) {
|
while ( second[j] !== undefined ) {
|
||||||
first[ i++ ] = second[ j++ ];
|
first[ i++ ] = second[ j++ ];
|
||||||
|
@ -272,8 +272,8 @@ jQuery.extend({
|
|||||||
type = "number";
|
type = "number";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that NaN and null values aren't set. See: #7116
|
// Make sure that null and NaN values aren't set. See: #7116
|
||||||
if ( value == null || type === "number" && isNaN( value ) ) {
|
if ( value == null || value !== value ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user