Core: Arrays like [42] should fail .isNumeric()

Fixes #14179
This commit is contained in:
Dave Methvin 2014-03-03 22:18:50 -05:00
parent 279913c71b
commit 10efa1f5b4
2 changed files with 4 additions and 2 deletions

View File

@ -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 ) {

View File

@ -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");