diff --git a/es5-shim.js b/es5-shim.js index 6296b64d..bbd01991 100644 --- a/es5-shim.js +++ b/es5-shim.js @@ -2003,6 +2003,12 @@ parseInt = (function (origParseInt) { var hexRegex = /^[-+]?0[xX]/; return function parseInt(str, radix) { + if (typeof str === 'symbol') { + // handle Symbols in node 8.3/8.4 + // eslint-disable-next-line no-implicit-coercion, no-unused-expressions + '' + str; // jscs:ignore disallowImplicitTypeConversion + } + var string = trim(String(str)); var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10); return origParseInt(string, defaultedRadix); diff --git a/tests/spec/s-global.js b/tests/spec/s-global.js index 515553ed..b7bbc9be 100644 --- a/tests/spec/s-global.js +++ b/tests/spec/s-global.js @@ -6,6 +6,8 @@ describe('global methods', function () { var foo = function foo() {}; var functionsHaveNames = foo.name === 'foo'; var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit; + var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'; + var ifSymbolsIt = hasSymbols ? it : xit; var is = function (x, y) { if (x === 0 && y === 0) { @@ -74,6 +76,11 @@ describe('global methods', function () { expect(parseInt(null)).toBeNaN(); expect(parseInt(NaN)).toBeNaN(); }); + + ifSymbolsIt('throws on symbols', function () { + expect(function () { parseInt(Symbol('')); }).toThrow(); + expect(function () { parseInt(Object(Symbol(''))); }).toThrow(); + }); /* eslint-enable radix */ });