From 68213f20bb5d5426f99bafde028ecab601a9d105 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. (cherry picked from commit 0bc0a69026ce4c1ac570a729d3c975a4a55d0ff4) --- src/core.js | 5 ++++- src/css.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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; } -- 2.39.5