Skip to content

Commit 6cf4503

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

File tree

10 files changed

+32
-21
lines changed

10 files changed

+32
-21
lines changed

doc/api/cli.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,6 @@ when `Error.stack` is accessed. If you access `Error.stack` frequently
353353
in your application, take into account the performance implications
354354
of `--enable-source-maps`.
355355

356-
### `--experimental-global-customevent`
357-
358-
<!-- YAML
359-
added: v18.7.0
360-
-->
361-
362-
Expose the [CustomEvent Web API][] on the global scope.
363-
364356
### `--experimental-global-webcrypto`
365357

366358
<!-- YAML
@@ -462,6 +454,14 @@ added: v18.0.0
462454

463455
Disable experimental support for the [Fetch API][].
464456

457+
### `--no-experimental-global-customevent`
458+
459+
<!-- YAML
460+
added: REPLACEME
461+
-->
462+
463+
Disable exposition of [CustomEvent Web API][] on the global scope.
464+
465465
### `--no-experimental-repl-await`
466466

467467
<!-- YAML
@@ -1966,7 +1966,6 @@ Node.js options that are allowed are:
19661966
* `--enable-source-maps`
19671967
* `--experimental-abortcontroller`
19681968
* `--experimental-default-type`
1969-
* `--experimental-global-customevent`
19701969
* `--experimental-global-webcrypto`
19711970
* `--experimental-import-meta-resolve`
19721971
* `--experimental-json-modules`
@@ -2000,6 +1999,7 @@ Node.js options that are allowed are:
20001999
* `--no-addons`
20012000
* `--no-deprecation`
20022001
* `--no-experimental-fetch`
2002+
* `--no-experimental-global-customevent`
20032003
* `--no-experimental-repl-await`
20042004
* `--no-extra-info-on-fatal-exception`
20052005
* `--no-force-async-hooks-checks`

doc/api/globals.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,14 @@ only if the Node.js binary was compiled with including support for the
390390

391391
<!-- YAML
392392
added: v18.7.0
393+
changes:
394+
- version: REPLACEME
395+
pr-url: https://github.com/nodejs/node/pull/44860
396+
description: No longer behind `--experimental-global-customevent` CLI flag.
393397
-->
394398

395-
> Stability: 1 - Experimental. Enable this API with the
396-
> [`--experimental-global-customevent`][] CLI flag.
399+
> Stability: 1 - Experimental. Disable this API with the
400+
> [`--no-experimental-global-customevent`][] CLI flag.
397401
398402
<!-- type=global -->
399403

@@ -888,6 +892,7 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
888892
[`--experimental-global-customevent`]: cli.md#--experimental-global-customevent
889893
[`--experimental-global-webcrypto`]: cli.md#--experimental-global-webcrypto
890894
[`--no-experimental-fetch`]: cli.md#--no-experimental-fetch
895+
[`--no-experimental-global-customevent`]: cli.md#--no-experimental-global-customevent
891896
[`AbortController`]: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
892897
[`ByteLengthQueuingStrategy`]: webstreams.md#class-bytelengthqueuingstrategy
893898
[`CompressionStream`]: webstreams.md#class-compressionstream

doc/node.1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,6 @@ Interpret as either ES modules or CommonJS modules input via --eval or STDIN, wh
145145
.js or extensionless files with no sibling or parent package.json;
146146
.js or extensionless files whose nearest parent package.json lacks a "type" field, unless under node_modules.
147147
.
148-
.It Fl -experimental-global-customevent
149-
Expose the CustomEvent on the global scope.
150-
.
151148
.It Fl -experimental-global-webcrypto
152149
Expose the Web Crypto API on the global scope.
153150
.
@@ -174,6 +171,9 @@ Enable code coverage in the test runner.
174171
.It Fl -no-experimental-fetch
175172
Disable experimental support for the Fetch API.
176173
.
174+
.It Fl -no-experimental-global-customevent
175+
Disable exposition of the CustomEvent on the global scope.
176+
.
177177
.It Fl -no-experimental-repl-await
178178
Disable top-level await keyword support in REPL.
179179
.

lib/internal/process/pre_execution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ function setupCodeCoverage() {
345345
// removed.
346346
function setupCustomEvent() {
347347
if (process.config.variables.node_no_browser_globals ||
348-
!getOptionValue('--experimental-global-customevent')) {
348+
getOptionValue('--no-experimental-global-customevent')) {
349349
return;
350350
}
351351
const { CustomEvent } = require('internal/event_target');

src/node_options.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
385385
AddOption("--experimental-global-customevent",
386386
"expose experimental CustomEvent on the global scope",
387387
&EnvironmentOptions::experimental_global_customevent,
388-
kAllowedInEnvvar);
388+
kAllowedInEnvironment,
389+
true);
389390
AddOption("--experimental-global-webcrypto",
390391
"expose experimental Web Crypto API on the global scope",
391392
&EnvironmentOptions::experimental_global_web_crypto,

src/node_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class EnvironmentOptions : public Options {
111111
std::string dns_result_order;
112112
bool enable_source_maps = false;
113113
bool experimental_fetch = true;
114-
bool experimental_global_customevent = false;
114+
bool experimental_global_customevent = true;
115115
bool experimental_global_web_crypto = false;
116116
bool experimental_https_modules = false;
117117
std::string experimental_specifier_resolution;
Lines changed: 7 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 2 deletions
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)