-
Notifications
You must be signed in to change notification settings - Fork 136
WeakMap and WeakSet errors #111
Copy link
Copy link
Open
Description
The following clone test of an array containing a WeakMap produces an error:
// WeakMap test
const options = { includeNonEnumerable: true };
let wm = new WeakMap();
let obj = { foo: "I am foo" };
wm.set(obj, 42);
let src = [1, 2, wm, "bar"];
let dest = clone(src, options);
dest[1] = 3.1416;
console.log(src);
// [ 1, 2, WeakMap { <items unknown> }, 'bar' ]
console.log(dest);
// [ 1, 3.1416, WeakMap {}, 'bar' ]
let destMap = dest[2];
console.log(destMap instanceof WeakMap);
// true
destMap.has(obj);
// TypeError: Method WeakMap.prototype.has called on incompatible receiver #<WeakMap>An identical error occurs when running a similar test with WeakSet:
// TypeError: Method WeakSet.prototype.has called on incompatible receiver #<WeakSet>Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels