Skip to content

Commit

Permalink
Ref #14313: NaN detection. Close gh-1352.
Browse files Browse the repository at this point in the history
(cherry picked from commit 0bc0a69)
  • Loading branch information
gibson042 committed Sep 12, 2013
1 parent 1d57ffe commit 68213f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/core.js
Expand Up @@ -221,7 +221,10 @@ jQuery.extend({
}, },


isNumeric: function( obj ) { 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 ) { type: function( obj ) {
Expand Down
4 changes: 2 additions & 2 deletions src/css.js
Expand Up @@ -273,8 +273,8 @@ jQuery.extend({
type = "number"; type = "number";
} }


// Make sure that NaN and null values aren't set. See: #7116 // Make sure that null and NaN values aren't set. See: #7116
if ( value == null || type === "number" && isNaN( value ) ) { if ( value == null || value !== value ) {
return; return;
} }


Expand Down

0 comments on commit 68213f2

Please sign in to comment.