Permalink
Browse files

lib: do not register DOMException in a module

Instead of registering it in a global scope of a native module
and expecting that it only gets evaluated when the module is actually
compiled and run and will not be evaluated because the module can
be cached, directly register the DOMException constructor
onto Environment during bootstrap for clarity, since this is
a side effect that has to happen during bootstrap.

PR-URL: #24708
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
joyeecheung committed Nov 28, 2018
1 parent 2931c50 commit 976065d9cb88a118c0238a8518a2570b28cce817
Showing with 3 additions and 4 deletions.
  1. +3 −1 lib/internal/bootstrap/node.js
  2. +0 −3 lib/internal/domexception.js
@@ -566,7 +566,9 @@
function setupDOMException() {
// Registers the constructor with C++.
NativeModule.require('internal/domexception');
const DOMException = NativeModule.require('internal/domexception');
const { registerDOMException } = internalBinding('messaging');
registerDOMException(DOMException);
}
function setupInspector(originalConsole, wrappedConsole) {
@@ -1,6 +1,5 @@
'use strict';
const { registerDOMException } = internalBinding('messaging');
const { ERR_INVALID_THIS } = require('internal/errors').codes;
const internalsMap = new WeakMap();
@@ -85,5 +84,3 @@ for (const [name, codeName, value] of [
}
module.exports = DOMException;
registerDOMException(DOMException);

0 comments on commit 976065d

Please sign in to comment.