diff --git a/CHANGELOG.md b/CHANGELOG.md index 26abcdca5b32..778e06f28db1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ - `Number.range` Stage 1 proposal and method [renamed to `Iterator.range`](https://github.com/tc39/proposal-Number.range) - `Function.prototype.unThis` Stage 0 proposal and method [renamed to `Function.prototype.demethodize`](https://github.com/js-choi/proposal-function-demethodize) - Improved some cases handling of array-replacer in `JSON.stringify` symbols handling fix -- Fixed many other old `JSON.{ parse, stringify }` bugs (numbers instead of strings as keys in replacer, handling negative zeroes, some more handling symbols cases, etc.) +- Fixed many other old `JSON.{ parse, stringify }` bugs (numbers instead of strings as keys in replacer, handling negative zeroes, spaces, some more handling symbols cases, etc.) - Fixed configurability and `ToString` conversion of some accessors - Added Opera Android 73 compat data mapping - Added TypeScript definitions to `core-js-builder` diff --git a/packages/core-js/modules/esnext.json.parse.js b/packages/core-js/modules/esnext.json.parse.js index a8b65c3502e7..d7549d0704a7 100644 --- a/packages/core-js/modules/esnext.json.parse.js +++ b/packages/core-js/modules/esnext.json.parse.js @@ -240,17 +240,22 @@ Context.prototype = { var NO_SOURCE_SUPPORT = fails(function () { var unsafeInt = '9007199254740993'; var source; - JSON.parse(unsafeInt, function (key, value, context) { + nativeParse(unsafeInt, function (key, value, context) { source = context.source; }); return source !== unsafeInt; }); +var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () { + // Safari 9 bug + return 1 / nativeParse('-0 \t') !== -Infinity; +}); + // `JSON.parse` method // https://tc39.es/ecma262/#sec-json.parse // https://github.com/tc39/proposal-json-parse-with-source $({ target: 'JSON', stat: true, forced: NO_SOURCE_SUPPORT }, { parse: function parse(text, reviver) { - return NATIVE_SYMBOL && nativeParse && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver); + return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver); } });