From 914d6c9ab8cd7154c075867f3894bd90b8e252ea Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 10 Apr 2019 16:47:44 +0800 Subject: [PATCH] lib: use primordials in domexception.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/27171 Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- lib/internal/per_context/domexception.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/internal/per_context/domexception.js b/lib/internal/per_context/domexception.js index 729fe3757ada5b..83b8d55995201d 100644 --- a/lib/internal/per_context/domexception.js +++ b/lib/internal/per_context/domexception.js @@ -1,8 +1,11 @@ 'use strict'; -// `per_context` scripts are executed before creating the primordials so we -// cannot use them here. -/* eslint-disable no-restricted-globals */ +const { + SafeWeakMap, + SafeMap, + Object, + Symbol +} = primordials; class ERR_INVALID_THIS extends TypeError { constructor(type) { @@ -12,9 +15,9 @@ class ERR_INVALID_THIS extends TypeError { get code() { return 'ERR_INVALID_THIS'; } } -const internalsMap = new WeakMap(); +const internalsMap = new SafeWeakMap(); -const nameToCodeMap = new Map(); +const nameToCodeMap = new SafeMap(); class DOMException extends Error { constructor(message = '', name = 'Error') {