From 0bc0a69026ce4c1ac570a729d3c975a4a55d0ff4 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 5 Sep 2013 14:04:11 -0400 Subject: [PATCH] Ref #14313: NaN detection. Close gh-1352. --- src/core.js | 7 +++++-- src/css.js | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core.js b/src/core.js index 7e190a480..9b1bb6257 100644 --- a/src/core.js +++ b/src/core.js @@ -224,7 +224,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; }, isEmptyObject: function( obj ) { @@ -426,7 +429,7 @@ jQuery.extend({ } // 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 ) { while ( second[j] !== undefined ) { first[ i++ ] = second[ j++ ]; diff --git a/src/css.js b/src/css.js index 2a18aa4fc..a4d0b55df 100644 --- a/src/css.js +++ b/src/css.js @@ -272,8 +272,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; } -- 2.39.5