镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Commit 96036ef

Browse files
joyeecheungBethGriggs
authored andcommitted
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>
1 parent dacdd01 commit 96036ef

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

‎lib/internal/bootstrap/node.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,9 @@
434434

435435
function setupDOMException() {
436436
// Registers the constructor with C++.
437-
NativeModule.require('internal/domexception');
437+
const DOMException = NativeModule.require('internal/domexception');
438+
const { registerDOMException } = internalBinding('messaging');
439+
registerDOMException(DOMException);
438440
}
439441

440442
function setupInspector(originalConsole, wrappedConsole) {

‎lib/internal/domexception.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

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

65
const internalsMap = new WeakMap();
@@ -85,5 +84,3 @@ for (const [name, codeName, value] of [
8584
}
8685

8786
module.exports = DOMException;
88-
89-
registerDOMException(DOMException);

0 commit comments

Comments
 (0)