Permalink
Browse files

Core: make isNumeric test work on Symbol

Ref #2645
Closes #2657

(cherry picked from commit 0703fd5)
  • Loading branch information...
LizaLemons authored and gibson042 committed Oct 17, 2015
1 parent 20cd343 commit d846c25dca4adeb4262f98957f1b887fe6b29912
Showing with 9 additions and 1 deletion.
  1. +2 −1 src/core.js
  2. +7 −0 test/unit/core.js
View
@@ -221,7 +221,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;
},
isEmptyObject: function( obj ) {
View
@@ -504,6 +504,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 );

0 comments on commit d846c25

Please sign in to comment.