From b0a00557f7f2891ad0f2069ace52f3c15d91390b Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Thu, 30 Nov 2023 14:53:05 +0700 Subject: [PATCH] fix the order of arguments validation in `Array` iteration methods, close #1313 --- CHANGELOG.md | 1 + packages/core-js/internals/array-iteration-from-last.js | 2 +- packages/core-js/internals/array-iteration.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfa0185f0ecc..60f3389397c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Moved to stable ES, [November 2023 TC39 meeting](https://twitter.com/robpalmer2/status/1729216597623976407) - Added `es.` namespace module, `/es/` and `/stable/` namespaces entries - Fixed `@@toStringTag` property descriptors on DOM collections, [#1312](https://github.com/zloirock/core-js/issues/1312) +- Fixed the order of arguments validation in `Array` iteration methods, [#1313](https://github.com/zloirock/core-js/issues/1313) - Some minor `atob` / `btoa` improvements - Compat data improvements: - [`Promise.withResolvers`](https://github.com/tc39/proposal-promise-with-resolvers) marked as shipped from FF121 diff --git a/packages/core-js/internals/array-iteration-from-last.js b/packages/core-js/internals/array-iteration-from-last.js index ff9d511985b0..aa797243b1aa 100644 --- a/packages/core-js/internals/array-iteration-from-last.js +++ b/packages/core-js/internals/array-iteration-from-last.js @@ -10,8 +10,8 @@ var createMethod = function (TYPE) { return function ($this, callbackfn, that) { var O = toObject($this); var self = IndexedObject(O); - var boundFunction = bind(callbackfn, that); var index = lengthOfArrayLike(self); + var boundFunction = bind(callbackfn, that); var value, result; while (index-- > 0) { value = self[index]; diff --git a/packages/core-js/internals/array-iteration.js b/packages/core-js/internals/array-iteration.js index 4abd8bd89870..689c885452be 100644 --- a/packages/core-js/internals/array-iteration.js +++ b/packages/core-js/internals/array-iteration.js @@ -20,8 +20,8 @@ var createMethod = function (TYPE) { return function ($this, callbackfn, that, specificCreate) { var O = toObject($this); var self = IndexedObject(O); - var boundFunction = bind(callbackfn, that); var length = lengthOfArrayLike(self); + var boundFunction = bind(callbackfn, that); var index = 0; var create = specificCreate || arraySpeciesCreate; var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;