This would cause the #refSet to possibly contain dead references and lead to a key/value pair being yielded multiple times.
const m = new IterableWeakMap();
const a = { [Symbol.toStringTag]: "A" };
const b = { [Symbol.toStringTag]: "B" };
m.set(a, 1);
m.set(b, 2);
m.set(a, 3);
for (const { 0: key, 1: value } of m) {
// This would previously log:
// [object A] 3
// [object B] 2
// [object A] 3
console.log(key, value);
}
It also applies some fixes so that new IterableWeakMap() doesn’t throw a TypeError, because undefined is not iterable and makes IterableWeakMap.length === WeakMap.length.
Fixes: https://github.com/tc39/proposal-weakrefs/issues/213
This would cause the
#refSet
to possibly contain dead references and lead to a key/value pair being yielded multiple times.It also applies some fixes so that
new IterableWeakMap()
doesn’t throw aTypeError
, becauseundefined
is not iterable and makesIterableWeakMap.length === WeakMap.length
.