Skip to content

Commit c87b20a

Browse files
committed
update validation order of WeakMap.prototype.getOrInsertComputed
tc39/proposal-upsert#79
1 parent 48bafc9 commit c87b20a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Changelog
22
##### Unreleased
3+
- Validation order of [`WeakMap.prototype.getOrInsertComputed`](https://github.com/tc39/proposal-upsert) updated following [proposal-upsert/79](https://github.com/tc39/proposal-upsert/pull/79)
34
- Compat data improvements:
45
- [Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management) features disabled (again) in V8 ~ Chromium 135 and re-added in 136
56
- [`RegExp.escape`](https://github.com/tc39/proposal-regex-escaping) marked as [shipped from V8 ~ Chromium 136](https://issues.chromium.org/issues/353856236#comment17)
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
var WeakMapHelpers = require('../internals/weak-map-helpers');
3+
4+
var weakmap = new WeakMapHelpers.WeakMap();
5+
var set = WeakMapHelpers.set;
6+
var remove = WeakMapHelpers.remove;
7+
8+
module.exports = function (key) {
9+
set(weakmap, key, 1);
10+
remove(weakmap, key);
11+
return key;
12+
};

packages/core-js/modules/esnext.weak-map.get-or-insert-computed.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
var $ = require('../internals/export');
33
var aCallable = require('../internals/a-callable');
44
var aWeakMap = require('../internals/a-weak-map');
5+
var aWeakKey = require('../internals/a-weak-key');
56
var WeakMapHelpers = require('../internals/weak-map-helpers');
67

78
var get = WeakMapHelpers.get;
@@ -13,9 +14,9 @@ var set = WeakMapHelpers.set;
1314
$({ target: 'WeakMap', proto: true, real: true, forced: true }, {
1415
getOrInsertComputed: function getOrInsertComputed(key, callbackfn) {
1516
aWeakMap(this);
17+
aWeakKey(key);
1618
aCallable(callbackfn);
1719
if (has(this, key)) return get(this, key);
18-
set(this, key); // key validation
1920
var value = callbackfn(key);
2021
set(this, key, value);
2122
return value;

0 commit comments

Comments
 (0)