mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Ref #14313: NaN detection. Close gh-1352.
(cherry picked from commit 0bc0a69026)
This commit is contained in:
@@ -221,7 +221,10 @@ jQuery.extend({
|
||||
},
|
||||
|
||||
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;
|
||||
},
|
||||
|
||||
type: function( obj ) {
|
||||
|
||||
@@ -273,8 +273,8 @@ jQuery.extend({
|
||||
type = "number";
|
||||
}
|
||||
|
||||
// Make sure that NaN and null values aren't set. See: #7116
|
||||
if ( value == null || type === "number" && isNaN( value ) ) {
|
||||
// Make sure that null and NaN values aren't set. See: #7116
|
||||
if ( value == null || value !== value ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user