Skip to content

Commit

Permalink
lib: do not register DOMException in a module
Browse files Browse the repository at this point in the history
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 30, 2018
1 parent 2931c50 commit 976065d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions lib/internal/domexception.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { registerDOMException } = internalBinding('messaging');
const { ERR_INVALID_THIS } = require('internal/errors').codes;

const internalsMap = new WeakMap();
Expand Down Expand Up @@ -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.