]> 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:45:12 +0000 (16:45 -0400)
(cherry picked from commit 0bc0a69026ce4c1ac570a729d3c975a4a55d0ff4)

src/core.js
src/css.js

index 599caba6441c7b9005f4cd3b0e62858cd7a05f2d..0a8ba38930a63a6c4e0449a2b7c3c7e67f33f7d1 100644 (file)
@@ -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 ) {
index ee6a3935bd82f701b92483c4f7ae21c3378f683f..883adf1aea61349526fffb7d71aff42d5d8141a6 100644 (file)
@@ -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;
                        }