From 0703fd52ef88a2cdac93502070c51c93ffa1dfdd Mon Sep 17 00:00:00 2001 From: Liza Ramo Date: Sat, 17 Oct 2015 16:48:57 -0400 Subject: Core: make isNumeric test work on Symbol Ref #2645 Closes #2657 --- src/core.js | 3 ++- test/unit/core.js | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index b1483c018..a31e5f93f 100644 --- a/src/core.js +++ b/src/core.js @@ -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 ) { diff --git a/test/unit/core.js b/test/unit/core.js index 33d162d68..26602dcb2 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -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 ); -- cgit v1.2.3