diff --git a/CHANGELOG.md b/CHANGELOG.md index 62320ab46951..ebe0ba8c08a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Moved to Stage 3, [March TC39 meeting](https://github.com/babel/proposals/issues/81#issuecomment-1083449843) - `Array.prototype.toSpliced` throws a `TypeError` instead of `RangeError` if the result length is more than `MAX_SAFE_INTEGER`, [proposal-change-array-by-copy/70](https://github.com/tc39/proposal-change-array-by-copy/pull/70) - Added some more `atob` / `btoa` fixes: + - NodeJS <17.9 `atob` does not ignore spaces, [node/42530](https://github.com/nodejs/node/issues/42530) + - Actual NodeJS `atob` does not validate encoding, [node/42646](https://github.com/nodejs/node/issues/42646) - FF26- implementation does not properly convert argument to string - IE / Edge <16 implementation have wrong arity - Significant internal refactoring and splitting of modules (but without exposing to public API since it will be a breaking change - it will be exposed in the next major version) @@ -13,7 +15,6 @@ - Tooling: - Stabilized proposals are filtered out from the `core-js-compat` -> `core-js-builder` -> `core-js-bundle` output. That mean that if the output contains, for example, `es.object.has-own`, the legacy reference to it, `esnext.object.has-own`, will not be added. - Compat data: - - `atob` marked as not supported in the actual NodeJS (again) because of [the bug](https://github.com/nodejs/node/issues/42530) - `.stack` property on `DOMException` marked as supported from Deno [1.15](https://github.com/denoland/deno/releases/tag/v1.15.0) - Added Deno 1.21 compat data mapping - Added Electron 19.0 and updated 18.0 compat data mapping diff --git a/packages/core-js-compat/src/data.mjs b/packages/core-js-compat/src/data.mjs index 7121bf6b8638..858b0b4b4cce 100644 --- a/packages/core-js-compat/src/data.mjs +++ b/packages/core-js-compat/src/data.mjs @@ -1915,7 +1915,8 @@ export const data = { firefox: '27', // https://github.com/nodejs/node/issues/41450 // https://github.com/nodejs/node/issues/42530 - // node: '17.5', '16.0', + // https://github.com/nodejs/node/issues/42646 + // node: '17.9', 17.5', '16.0', opera: '10.5', safari: '10.1', }, diff --git a/packages/core-js/modules/web.atob.js b/packages/core-js/modules/web.atob.js index 3e0761b1b5d3..d9674712c2b9 100644 --- a/packages/core-js/modules/web.atob.js +++ b/packages/core-js/modules/web.atob.js @@ -18,18 +18,22 @@ var replace = uncurryThis(''.replace); var exec = uncurryThis(disallowed.exec); var NO_SPACES_IGNORE = fails(function () { - return atob(' ') !== ''; + return $atob(' ') !== ''; }); -var NO_ARG_RECEIVING_CHECK = !NO_SPACES_IGNORE && !fails(function () { +var NO_ENCODING_CHECK = !fails(function () { + $atob('a'); +}); + +var NO_ARG_RECEIVING_CHECK = !NO_SPACES_IGNORE && !NO_ENCODING_CHECK && !fails(function () { $atob(); }); -var WRONG_ARITY = !NO_SPACES_IGNORE && $atob.length !== 1; +var WRONG_ARITY = !NO_SPACES_IGNORE && !NO_ENCODING_CHECK && $atob.length !== 1; // `atob` method // https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob -$({ global: true, enumerable: true, forced: NO_SPACES_IGNORE || NO_ARG_RECEIVING_CHECK || WRONG_ARITY }, { +$({ global: true, enumerable: true, forced: NO_SPACES_IGNORE || NO_ENCODING_CHECK || NO_ARG_RECEIVING_CHECK || WRONG_ARITY }, { atob: function atob(data) { validateArgumentsLength(arguments.length, 1); if (NO_ARG_RECEIVING_CHECK || WRONG_ARITY) return $atob(data); diff --git a/tests/compat/tests.js b/tests/compat/tests.js index f5990501f60e..3c3978d1fbed 100644 --- a/tests/compat/tests.js +++ b/tests/compat/tests.js @@ -1696,8 +1696,12 @@ GLOBAL.tests = { 'web.atob': function () { try { atob(); - } catch (error) { - return atob(' ') === ''; + } catch (error1) { + try { + atob('a'); + } catch (error2) { + return atob(' ') === ''; + } } }, 'web.btoa': function () {