aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2011-10-11 21:04:22 -0400
committerDave Methvin <dave.methvin@gmail.com>2011-10-11 21:04:22 -0400
commit83c08ffa1ffa778e41d728ed7fa49044dd7135f9 (patch)
tree47c0d05e46556664e9e07277a727f395f6888bca /src
parent6afc2c074bec5c19063c8f8ebca6bfb53c7d4cef (diff)
downloadjquery-83c08ffa1ffa778e41d728ed7fa49044dd7135f9.tar.gz
jquery-83c08ffa1ffa778e41d728ed7fa49044dd7135f9.zip
Fix #10478. Replace jQuery.isNaN with jQuery.isNumeric.
Thanks to Christian C. Salvadó for the unit tests!
Diffstat (limited to 'src')
-rw-r--r--src/core.js4
-rw-r--r--src/css.js2
-rw-r--r--src/data.js2
-rw-r--r--src/dimensions.js2
4 files changed, 5 insertions, 5 deletions
diff --git a/src/core.js b/src/core.js
index 7f30edea2..e28c1b524 100644
--- a/src/core.js
+++ b/src/core.js
@@ -483,8 +483,8 @@ jQuery.extend({
return obj && typeof obj === "object" && "setInterval" in obj;
},
- isNaN: function( obj ) {
- return obj == null || !rdigit.test( obj ) || isNaN( obj );
+ isNumeric: function( obj ) {
+ return obj != null && rdigit.test( obj ) && !isNaN( obj );
},
type: function( obj ) {
diff --git a/src/css.js b/src/css.js
index 76c2255ce..2adfdffe1 100644
--- a/src/css.js
+++ b/src/css.js
@@ -211,7 +211,7 @@ if ( !jQuery.support.opacity ) {
set: function( elem, value ) {
var style = elem.style,
currentStyle = elem.currentStyle,
- opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",
+ opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
filter = currentStyle && currentStyle.filter || style.filter || "";
// IE has trouble with opacity if it does not have layout
diff --git a/src/data.js b/src/data.js
index 0ce3b7d66..02f96a849 100644
--- a/src/data.js
+++ b/src/data.js
@@ -323,7 +323,7 @@ function dataAttr( elem, key, data ) {
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
- !jQuery.isNaN( data ) ? parseFloat( data ) :
+ jQuery.isNumeric( data ) ? parseFloat( data ) :
rbrace.test( data ) ? jQuery.parseJSON( data ) :
data;
} catch( e ) {}
diff --git a/src/dimensions.js b/src/dimensions.js
index 7df0d5ddf..d339817c9 100644
--- a/src/dimensions.js
+++ b/src/dimensions.js
@@ -61,7 +61,7 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
var orig = jQuery.css( elem, type ),
ret = parseFloat( orig );
- return jQuery.isNaN( ret ) ? orig : ret;
+ return jQuery.isNumeric( ret ) ? ret : orig;
// Set the width or height on the element (default to pixels if value is unitless)
} else {