From: Richard Gibson Date: Thu, 5 Sep 2013 18:04:11 +0000 (-0400) Subject: Ref #14313: NaN detection. Close gh-1352. X-Git-Tag: 1.11.0-beta1~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0bc0a69026ce4c1ac570a729d3c975a4a55d0ff4;p=jquery.git Ref #14313: NaN detection. Close gh-1352. --- 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; }