diff --git a/lib/internal/per_context/primordials.js b/lib/internal/per_context/primordials.js index baaca6d273f86c..6a14d110e8681f 100644 --- a/lib/internal/per_context/primordials.js +++ b/lib/internal/per_context/primordials.js @@ -84,21 +84,31 @@ primordials.makeSafe = makeSafe; // Subclass the constructors because we need to use their prototype // methods later. +// Defining the `constructor` is necessary here to avoid the default +// constructor which uses the user-mutable `%ArrayIteratorPrototype%.next`. primordials.SafeMap = makeSafe( Map, - class SafeMap extends Map {} + class SafeMap extends Map { + constructor(i) { super(i); } // eslint-disable-line no-useless-constructor + } ); primordials.SafeWeakMap = makeSafe( WeakMap, - class SafeWeakMap extends WeakMap {} + class SafeWeakMap extends WeakMap { + constructor(i) { super(i); } // eslint-disable-line no-useless-constructor + } ); primordials.SafeSet = makeSafe( Set, - class SafeSet extends Set {} + class SafeSet extends Set { + constructor(i) { super(i); } // eslint-disable-line no-useless-constructor + } ); primordials.SafeWeakSet = makeSafe( WeakSet, - class SafeWeakSet extends WeakSet {} + class SafeWeakSet extends WeakSet { + constructor(i) { super(i); } // eslint-disable-line no-useless-constructor + } ); // Create copies of the namespace objects