Skip to content

Commit

Permalink
Core: make isNumeric test work on Symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
LizaLemons committed Oct 17, 2015
1 parent 44f8239 commit 83323f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core.js
Expand Up @@ -214,7 +214,8 @@ jQuery.extend( {
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// subtraction forces infinities to NaN
// adding 1 corrects loss of precision from parseFloat (#15100)
return !jQuery.isArray( obj ) && ( obj - parseFloat( obj ) + 1 ) >= 0;
var realStringObj = obj && obj.toString();
return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
},

isPlainObject: function( obj ) {
Expand Down
7 changes: 7 additions & 0 deletions test/unit/core.js
Expand Up @@ -490,6 +490,13 @@ QUnit.test( "isNumeric", function( assert ) {
assert.equal( t( new Date() ), false, "Instance of a Date" );
} );

QUnit[ typeof Symbol === "function" ? "test" : "skip" ]( "isNumeric(Symbol)", function( assert ) {
assert.expect( 2 );

assert.equal( jQuery.isNumeric( Symbol() ), false, "Symbol" );
assert.equal( jQuery.isNumeric( Object( Symbol() ) ), false, "Symbol inside an object" );
} );

QUnit.test( "isXMLDoc - HTML", function( assert ) {
assert.expect( 4 );

Expand Down

0 comments on commit 83323f1

Please sign in to comment.