aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2013-09-05 14:04:11 -0400
committerRichard Gibson <richard.gibson@gmail.com>2013-09-12 16:45:12 -0400
commit68213f20bb5d5426f99bafde028ecab601a9d105 (patch)
treeb6be3db335d6ae08aa205288e8e9a4e886ef17a0 /src
parent1d57ffe5fff06928aac53813342d33ec6bddd531 (diff)
downloadjquery-68213f20bb5d5426f99bafde028ecab601a9d105.tar.gz
jquery-68213f20bb5d5426f99bafde028ecab601a9d105.zip
Ref #14313: NaN detection. Close gh-1352.
(cherry picked from commit 0bc0a69026ce4c1ac570a729d3c975a4a55d0ff4)
Diffstat (limited to 'src')
-rw-r--r--src/core.js5
-rw-r--r--src/css.js4
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;
}