Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: make safe primordials safe to construct #36428

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/internal/per_context/primordials.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
}
);
primordials.SafeWeakMap = makeSafe(
WeakMap,
class SafeWeakMap extends WeakMap {}
class SafeWeakMap extends WeakMap {
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
}
);
primordials.SafeSet = makeSafe(
Set,
class SafeSet extends Set {}
class SafeSet extends Set {
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
}
);
primordials.SafeWeakSet = makeSafe(
WeakSet,
class SafeWeakSet extends WeakSet {}
class SafeWeakSet extends WeakSet {
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
}
);

// Create copies of the namespace objects
Expand Down