aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2014-03-03 22:18:50 -0500
committerDave Methvin <dave.methvin@gmail.com>2014-03-04 20:40:23 -0500
commit10efa1f5b44046aab6bcc8423322a41923faa290 (patch)
treed5a132f4700db7b562d2e43e67b70c53ee32c2b9
parent279913c71b63da721fa2f118cdce150effbf773e (diff)
downloadjquery-10efa1f5b44046aab6bcc8423322a41923faa290.tar.gz
jquery-10efa1f5b44046aab6bcc8423322a41923faa290.zip
Core: Arrays like [42] should fail .isNumeric()
Fixes #14179
-rw-r--r--src/core.js2
-rw-r--r--test/unit/core.js4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/core.js b/src/core.js
index 311e360aa..c494d7a60 100644
--- a/src/core.js
+++ b/src/core.js
@@ -216,7 +216,7 @@ jQuery.extend({
// 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;
+ return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
},
isPlainObject: function( obj ) {
diff --git a/test/unit/core.js b/test/unit/core.js
index d781d261a..6801c7c0d 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -457,7 +457,7 @@ test("isFunction", function() {
});
test( "isNumeric", function() {
- expect( 36 );
+ expect( 38 );
var t = jQuery.isNumeric,
Traditionalists = /** @constructor */ function(n) {
@@ -505,6 +505,8 @@ test( "isNumeric", function() {
equal( t(Number.NEGATIVE_INFINITY), false, "Negative Infinity");
equal( t(rong), false, "Custom .toString returning non-number");
equal( t({}), false, "Empty object");
+ equal( t( [] ), false, "Empty array" );
+ equal( t( [ 42 ] ), false, "Array with one number" );
equal( t(function(){} ), false, "Instance of a function");
equal( t( new Date() ), false, "Instance of a Date");
equal( t(function(){} ), false, "Instance of a function");