Skip to content

Commit 8027099

Browse files
authored
lib: enable global CustomEvent by default
Refs: #43885 Signed-off-by: Daeyeon Jeong <[email protected]> PR-URL: #44860 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent a2fb3f9 commit 8027099

10 files changed

+32
-24
lines changed

doc/api/cli.md

+9-11
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,6 @@ when `Error.stack` is accessed. If you access `Error.stack` frequently
341341
in your application, take into account the performance implications
342342
of `--enable-source-maps`.
343343

344-
### `--experimental-global-customevent`
345-
346-
<!-- YAML
347-
added:
348-
- v18.7.0
349-
- v16.17.0
350-
-->
351-
352-
Expose the [CustomEvent Web API][] on the global scope.
353-
354344
### `--experimental-import-meta-resolve`
355345

356346
<!-- YAML
@@ -411,6 +401,14 @@ added: REPLACEME
411401

412402
Disable exposition of [Web Crypto API][] on the global scope.
413403

404+
### `--no-experimental-global-customevent`
405+
406+
<!-- YAML
407+
added: REPLACEME
408+
-->
409+
410+
Disable exposition of [CustomEvent Web API][] on the global scope.
411+
414412
### `--no-experimental-repl-await`
415413

416414
<!-- YAML
@@ -1829,7 +1827,6 @@ Node.js options that are allowed are:
18291827
* `--enable-fips`
18301828
* `--enable-source-maps`
18311829
* `--experimental-abortcontroller`
1832-
* `--experimental-global-customevent`
18331830
* `--experimental-import-meta-resolve`
18341831
* `--experimental-json-modules`
18351832
* `--experimental-loader`
@@ -1862,6 +1859,7 @@ Node.js options that are allowed are:
18621859
* `--no-addons`
18631860
* `--no-deprecation`
18641861
* `--no-experimental-fetch`
1862+
* `--no-experimental-global-customevent`
18651863
* `--no-experimental-global-webcrypto`
18661864
* `--no-experimental-repl-await`
18671865
* `--no-extra-info-on-fatal-exception`

doc/api/globals.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,14 @@ only if the Node.js binary was compiled with including support for the
400400
added:
401401
- v18.7.0
402402
- v16.17.0
403+
changes:
404+
- version: REPLACEME
405+
pr-url: https://github.com/nodejs/node/pull/44860
406+
description: No longer behind `--experimental-global-customevent` CLI flag.
403407
-->
404408

405-
> Stability: 1 - Experimental. Enable this API with the
406-
> [`--experimental-global-customevent`][] CLI flag.
409+
> Stability: 1 - Experimental. Disable this API with the
410+
> [`--no-experimental-global-customevent`][] CLI flag.
407411
408412
<!-- type=global -->
409413

@@ -947,8 +951,8 @@ added: v18.0.0
947951
A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
948952

949953
[Web Crypto API]: webcrypto.md
950-
[`--experimental-global-customevent`]: cli.md#--experimental-global-customevent
951954
[`--no-experimental-fetch`]: cli.md#--no-experimental-fetch
955+
[`--no-experimental-global-customevent`]: cli.md#--no-experimental-global-customevent
952956
[`--no-experimental-global-webcrypto`]: cli.md#--no-experimental-global-webcrypto
953957
[`AbortController`]: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
954958
[`ByteLengthQueuingStrategy`]: webstreams.md#class-bytelengthqueuingstrategy

doc/node.1

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ Requires Node.js to be built with
139139
.It Fl -enable-source-maps
140140
Enable Source Map V3 support for stack traces.
141141
.
142-
.It Fl -experimental-global-customevent
143-
Expose the CustomEvent on the global scope.
144-
.
145142
.It Fl -experimental-global-webcrypto
146143
Expose the Web Crypto API on the global scope.
147144
.
@@ -165,6 +162,9 @@ Use this flag to enable ShadowRealm support.
165162
.It Fl -no-experimental-fetch
166163
Disable experimental support for the Fetch API.
167164
.
165+
.It Fl -no-experimental-global-customevent
166+
Disable exposition of the CustomEvent on the global scope.
167+
.
168168
.It Fl -no-experimental-global-webcrypto
169169
Disable exposition of the Web Crypto API on the global scope.
170170
.

lib/internal/process/pre_execution.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function setupWebCrypto() {
278278
// removed.
279279
function setupCustomEvent() {
280280
if (process.config.variables.node_no_browser_globals ||
281-
!getOptionValue('--experimental-global-customevent')) {
281+
getOptionValue('--no-experimental-global-customevent')) {
282282
return;
283283
}
284284
const { CustomEvent } = require('internal/event_target');

src/node_options.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
358358
AddOption("--experimental-global-customevent",
359359
"expose experimental CustomEvent on the global scope",
360360
&EnvironmentOptions::experimental_global_customevent,
361-
kAllowedInEnvironment);
361+
kAllowedInEnvironment,
362+
true);
362363
AddOption("--experimental-global-webcrypto",
363364
"expose experimental Web Crypto API on the global scope",
364365
&EnvironmentOptions::experimental_global_web_crypto,

src/node_options.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class EnvironmentOptions : public Options {
109109
std::string dns_result_order;
110110
bool enable_source_maps = false;
111111
bool experimental_fetch = true;
112-
bool experimental_global_customevent = false;
112+
bool experimental_global_customevent = true;
113113
bool experimental_global_web_crypto = true;
114114
bool experimental_https_modules = false;
115115
bool experimental_wasm_modules = false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Flags: --no-experimental-global-customevent
2+
'use strict';
3+
4+
require('../common');
5+
const { strictEqual } = require('node:assert');
6+
7+
strictEqual(typeof CustomEvent, 'undefined');

test/parallel/test-global-customevent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flags: --experimental-global-customevent --expose-internals
1+
// Flags: --expose-internals
22
'use strict';
33

44
require('../common');

test/parallel/test-repl-tab-complete.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ putIn.run([
405405
'var custom = "test";',
406406
]);
407407
testMe.complete('cus', common.mustCall(function(error, data) {
408-
assert.deepStrictEqual(data, [['custom'], 'cus']);
408+
assert.deepStrictEqual(data, [['CustomEvent', 'custom'], 'cus']);
409409
}));
410410

411411
// Make sure tab completion doesn't crash REPL with half-baked proxy objects.

test/wpt/test-events.js

-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ const { WPTRunner } = require('../common/wpt');
44

55
const runner = new WPTRunner('dom/events');
66

7-
runner.setFlags(['--experimental-global-customevent']);
8-
97
runner.runJsTests();

0 commit comments

Comments
 (0)