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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung authored and rvagg committed Feb 28, 2019
1 parent a5d57e2 commit f8c5820
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 @@ -434,7 +434,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 f8c5820

Please sign in to comment.