]> source.dussan.org Git - jquery.git/commitdiff
Ref #14313: NaN detection. Close gh-1352.
authorRichard Gibson <richard.gibson@gmail.com>
Thu, 5 Sep 2013 18:04:11 +0000 (14:04 -0400)
committerRichard Gibson <richard.gibson@gmail.com>
Thu, 12 Sep 2013 20:42:18 +0000 (16:42 -0400)
src/core.js
src/css.js

index 7e190a48027bd977ac252201ee1231bc253f4a0a..9b1bb6257d2979027cced9712e7c72dc287d0103 100644 (file)
@@ -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++ ];
index 2a18aa4fc97f8c590e38be6abbab3e4f36a4cbdb..a4d0b55dfe036ebe915e053948bc13ec6b53c167 100644 (file)
@@ -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;
                        }