Skip to content

Commit dedf382

Browse files
committed
fix(runtime): weak collections builtin reads intrinsics from primordials
TypeError and Object.defineProperty came off globals user code can replace; the builtins' lint rule requires the primordials.
1 parent 3728164 commit dedf382

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎NativeScript/runtime/js/weak-collections.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// lost with it. Every other value passes through unchanged.
99

1010
const { unwrap, wrap } = binding;
11+
const { ObjectDefineProperty, TypeError } = primordials;
1112
const {
1213
FinalizationRegistry: NativeFinalizationRegistry,
1314
WeakMap: NativeWeakMap,
@@ -38,7 +39,7 @@ class WeakMap extends NativeWeakMap {
3839

3940
// V8 ships the upsert proposal; inherited, these would key on the wrapper.
4041
if (typeof NativeWeakMap.prototype.getOrInsert === "function") {
41-
Object.defineProperty(WeakMap.prototype, "getOrInsert", {
42+
ObjectDefineProperty(WeakMap.prototype, "getOrInsert", {
4243
value: function getOrInsert(key, value) {
4344
return NativeWeakMap.prototype.getOrInsert.call(this, unwrap(key, true), value);
4445
},
@@ -47,7 +48,7 @@ if (typeof NativeWeakMap.prototype.getOrInsert === "function") {
4748
});
4849
}
4950
if (typeof NativeWeakMap.prototype.getOrInsertComputed === "function") {
50-
Object.defineProperty(WeakMap.prototype, "getOrInsertComputed", {
51+
ObjectDefineProperty(WeakMap.prototype, "getOrInsertComputed", {
5152
value: function getOrInsertComputed(key, callbackfn) {
5253
if (typeof callbackfn !== "function") {
5354
throw new TypeError("WeakMap.prototype.getOrInsertComputed: callback is not a function");
@@ -102,7 +103,7 @@ class WeakRef extends NativeWeakRef {
102103

103104
// weak-ref.js gave the native prototype a `get` alias of `deref`; inherited
104105
// as is, it would hand out the lifetime key.
105-
Object.defineProperty(WeakRef.prototype, "get", {
106+
ObjectDefineProperty(WeakRef.prototype, "get", {
106107
value: WeakRef.prototype.deref,
107108
writable: true,
108109
configurable: true,
@@ -136,7 +137,7 @@ for (const [name, value] of [
136137
["WeakRef", WeakRef],
137138
["FinalizationRegistry", FinalizationRegistry],
138139
]) {
139-
Object.defineProperty(globalThis, name, {
140+
ObjectDefineProperty(globalThis, name, {
140141
value,
141142
writable: true,
142143
configurable: true,

0 commit comments

Comments
 (0)