From: Richard Gibson Date: Thu, 5 Sep 2013 18:04:11 +0000 (-0400) Subject: Ref #14313: NaN detection. Close gh-1352. X-Git-Tag: 2.1.0-beta1~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=68213f20bb5d5426f99bafde028ecab601a9d105;p=jquery.git Ref #14313: NaN detection. Close gh-1352. (cherry picked from commit 0bc0a69026ce4c1ac570a729d3c975a4a55d0ff4) --- diff --git a/src/core.js b/src/core.js index 599caba64..0a8ba3893 100644 --- a/src/core.js +++ b/src/core.js @@ -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 ) { diff --git a/src/css.js b/src/css.js index ee6a3935b..883adf1ae 100644 --- a/src/css.js +++ b/src/css.js @@ -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; }