diff --git a/CHANGELOG.md b/CHANGELOG.md index 160643c69c43..8d9f1450c496 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ##### Unreleased - Added a workaround of the Bun ~ 0.1.1 [bug](https://github.com/Jarred-Sumner/bun/issues/399) that define some globals with incorrect property descriptors and that causes a crash of `core-js` - Added a fix of the FF103+ `structuredClone` bugs ([1774866](https://bugzilla.mozilla.org/show_bug.cgi?id=1774866) (fixed in FF104) and [1777321](https://bugzilla.mozilla.org/show_bug.cgi?id=1777321) (still not fixed)) that now can clone errors, but `.stack` of the clone is an empty string +- Fixed `{ Map, WeakMap }.prototype.emplace` logic, [#1102](https://github.com/zloirock/core-js/issues/1102) - Fixed order of errors throwing on iterator helpers ##### [3.23.3 - 2022.06.26](https://github.com/zloirock/core-js/releases/tag/v3.23.3) diff --git a/packages/core-js/internals/map-emplace.js b/packages/core-js/internals/map-emplace.js index daf30cfa43d8..08c95d0ba070 100644 --- a/packages/core-js/internals/map-emplace.js +++ b/packages/core-js/internals/map-emplace.js @@ -10,9 +10,15 @@ module.exports = function emplace(key, handler) { var get = aCallable(map.get); var has = aCallable(map.has); var set = aCallable(map.set); - var value = (call(has, map, key) && 'update' in handler) - ? handler.update(call(get, map, key), key, map) - : handler.insert(key, map); - call(set, map, key, value); - return value; + var value, inserted; + if (call(has, map, key)) { + value = call(get, map, key); + if ('update' in handler) { + value = handler.update(value, key, map); + call(set, map, key, value); + } return value; + } + inserted = handler.insert(key, map); + call(set, map, key, inserted); + return inserted; };