aboutsummaryrefslogtreecommitdiffstats
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:42:18 -0400
commit0bc0a69026ce4c1ac570a729d3c975a4a55d0ff4 (patch)
treee8c1376e98de4128b5e4ffafb19abfab5170574b
parent3a552cdfa76e773cbd3e8c2ad4bb6be7a0569117 (diff)
downloadjquery-0bc0a69026ce4c1ac570a729d3c975a4a55d0ff4.tar.gz
jquery-0bc0a69026ce4c1ac570a729d3c975a4a55d0ff4.zip
Ref #14313: NaN detection. Close gh-1352.
-rw-r--r--src/core.js7
-rw-r--r--src/css.js4
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;
}