File tree Expand file tree Collapse file tree 13 files changed +68
-5
lines changed Open diff view settings
Expand file tree Collapse file tree 13 files changed +68
-5
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -321,6 +321,7 @@ module.exports = {
321321 ByteLengthQueuingStrategy : 'readable' ,
322322 CompressionStream : 'readable' ,
323323 CountQueuingStrategy : 'readable' ,
324+ CustomEvent : 'readable' ,
324325 Crypto : 'readable' ,
325326 CryptoKey : 'readable' ,
326327 DecompressionStream : 'readable' ,
Original file line number Diff line number Diff line change @@ -280,6 +280,14 @@ effort to report stack traces relative to the original source file.
280280Overriding ` Error.prepareStackTrace ` prevents ` --enable-source-maps ` from
281281modifying the stack trace.
282282
283+ ### ` --experimental-global-customevent `
284+
285+ <!-- YAML
286+ added: REPLACEME
287+ -->
288+
289+ Expose the [ CustomEvent Web API] [ ] on the global scope.
290+
283291### ` --experimental-global-webcrypto `
284292
285293<!-- YAML
@@ -1640,6 +1648,7 @@ Node.js options that are allowed are:
16401648* ` --enable-fips `
16411649* ` --enable-source-maps `
16421650* ` --experimental-abortcontroller `
1651+ * ` --experimental-global-customevent `
16431652* ` --experimental-global-webcrypto `
16441653* ` --experimental-import-meta-resolve `
16451654* ` --experimental-json-modules `
@@ -2064,6 +2073,7 @@ done
20642073[ #42511 ] : https://github.com/nodejs/node/issues/42511
20652074[ Chrome DevTools Protocol ] : https://chromedevtools.github.io/devtools-protocol/
20662075[ CommonJS ] : modules.md
2076+ [ CustomEvent Web API ] : https://dom.spec.whatwg.org/#customevent
20672077[ ECMAScript module loader ] : esm.md#loaders
20682078[ Fetch API ] : https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
20692079[ Modules loaders ] : packages.md#modules-loaders
Original file line number Diff line number Diff line change @@ -374,6 +374,19 @@ A browser-compatible implementation of {CryptoKey}. This global is available
374374only if the Node.js binary was compiled with including support for the
375375` node:crypto ` module.
376376
377+ ## ` CustomEvent `
378+
379+ <!-- YAML
380+ added: REPLACEME
381+ -->
382+
383+ > Stability: 1 - Experimental. Enable this API with the
384+ > [ ` --experimental-global-customevent ` ] [ ] CLI flag.
385+
386+ <!-- type=global -->
387+
388+ A browser-compatible implementation of the [ ` CustomEvent ` Web API] [ ] .
389+
377390## Class: ` DecompressionStream `
378391
379392<!-- YAML
@@ -834,12 +847,14 @@ added: v18.0.0
834847A browser-compatible implementation of [ ` WritableStreamDefaultWriter ` ] [ ] .
835848
836849[ Web Crypto API ] : webcrypto.md
850+ [ `--experimental-global-customevent` ] : cli.md#--experimental-global-customevent
837851[ `--experimental-global-webcrypto` ] : cli.md#--experimental-global-webcrypto
838852[ `--no-experimental-fetch` ] : cli.md#--no-experimental-fetch
839853[ `AbortController` ] : https://developer.mozilla.org/en-US/docs/Web/API/AbortController
840854[ `ByteLengthQueuingStrategy` ] : webstreams.md#class-bytelengthqueuingstrategy
841855[ `CompressionStream` ] : webstreams.md#class-compressionstream
842856[ `CountQueuingStrategy` ] : webstreams.md#class-countqueuingstrategy
857+ [ `CustomEvent` Web API ] : https://dom.spec.whatwg.org/#customevent
843858[ `DOMException` ] : https://developer.mozilla.org/en-US/docs/Web/API/DOMException
844859[ `DecompressionStream` ] : webstreams.md#class-decompressionstream
845860[ `EventTarget` and `Event` API ] : events.md#eventtarget-and-event-api
Original file line number Diff line number Diff line change @@ -139,6 +139,9 @@ Requires Node.js to be built with
139139.It Fl -enable-source-maps
140140Enable Source Map V3 support for stack traces.
141141.
142+ .It Fl -experimental-global-customevent
143+ Expose the CustomEvent on the global scope.
144+ .
142145.It Fl -experimental-global-webcrypto
143146Expose the Web Crypto API on the global scope.
144147.
Original file line number Diff line number Diff line change 4949 message : Use `const { CompressionStream } = require('internal/webstreams/compression')` instead of the global.
5050 - name : CountQueuingStrategy
5151 message : Use `const { CountQueuingStrategy } = require('internal/webstreams/queuingstrategies')` instead of the global.
52+ - name : CustomEvent
53+ message : Use `const { CustomEvent } = require('internal/event_target');` instead of the global.
5254 - name : DecompressionStream
5355 message : Use `const { DecompressionStream } = require('internal/webstreams/compression')` instead of the global.
5456 - name : DOMException
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ function prepareMainThreadExecution(expandArgv1 = false,
4444 setupWarningHandler ( ) ;
4545 setupFetch ( ) ;
4646 setupWebCrypto ( ) ;
47+ setupCustomEvent ( ) ;
4748
4849 // Resolve the coverage directory to an absolute path, and
4950 // overwrite process.env so that the original path gets passed
@@ -249,6 +250,17 @@ function setupWebCrypto() {
249250 }
250251}
251252
253+ // TODO(daeyeon): move this to internal/bootstrap/browser when the CLI flag is
254+ // removed.
255+ function setupCustomEvent ( ) {
256+ if ( process . config . variables . node_no_browser_globals ||
257+ ! getOptionValue ( '--experimental-global-customevent' ) ) {
258+ return ;
259+ }
260+ const { CustomEvent } = require ( 'internal/event_target' ) ;
261+ exposeInterface ( globalThis , 'CustomEvent' , CustomEvent ) ;
262+ }
263+
252264// Setup User-facing NODE_V8_COVERAGE environment variable that writes
253265// ScriptCoverage to a specified file.
254266function setupCoverageHooks ( dir ) {
@@ -567,6 +579,7 @@ module.exports = {
567579 setupWarningHandler,
568580 setupFetch,
569581 setupWebCrypto,
582+ setupCustomEvent,
570583 setupDebugEnv,
571584 setupPerfHooks,
572585 prepareMainThreadExecution,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const {
1919 setupWarningHandler,
2020 setupFetch,
2121 setupWebCrypto,
22+ setupCustomEvent,
2223 setupDebugEnv,
2324 setupPerfHooks,
2425 initializeDeprecations,
@@ -71,6 +72,7 @@ setupDebugEnv();
7172setupWarningHandler ( ) ;
7273setupFetch ( ) ;
7374setupWebCrypto ( ) ;
75+ setupCustomEvent ( ) ;
7476initializeSourceMapsHandlers ( ) ;
7577
7678// Since worker threads cannot switch cwd, we do not need to
Original file line number Diff line number Diff line change @@ -339,6 +339,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
339339 &EnvironmentOptions::experimental_fetch,
340340 kAllowedInEnvironment ,
341341 true );
342+ AddOption (" --experimental-global-customevent" ,
343+ " expose experimental CustomEvent on the global scope" ,
344+ &EnvironmentOptions::experimental_global_customevent,
345+ kAllowedInEnvironment );
342346 AddOption (" --experimental-global-webcrypto" ,
343347 " expose experimental Web Crypto API on the global scope" ,
344348 &EnvironmentOptions::experimental_global_web_crypto,
Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ class EnvironmentOptions : public Options {
108108 std::string dns_result_order;
109109 bool enable_source_maps = false ;
110110 bool experimental_fetch = true ;
111+ bool experimental_global_customevent = false ;
111112 bool experimental_global_web_crypto = false ;
112113 bool experimental_https_modules = false ;
113114 std::string experimental_specifier_resolution;
Original file line number Diff line number Diff line change @@ -315,6 +315,9 @@ if (hasCrypto && global.crypto) {
315315 knownGlobals . push ( global . CryptoKey ) ;
316316 knownGlobals . push ( global . SubtleCrypto ) ;
317317}
318+ if ( global . CustomEvent ) {
319+ knownGlobals . push ( global . CustomEvent ) ;
320+ }
318321if ( global . ReadableStream ) {
319322 knownGlobals . push (
320323 global . ReadableStream ,
You can’t perform that action at this time.
0 commit comments