Skip to content

Commit

Permalink
fix .emplace logic, #1102
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jul 8, 2022
1 parent 0134fd1 commit 0b5d53d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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)
Expand Down
16 changes: 11 additions & 5 deletions packages/core-js/internals/map-emplace.js
Expand Up @@ -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;
};

0 comments on commit 0b5d53d

Please sign in to comment.