Skip to content

Commit

Permalink
lib: enable global CustomEvent by default
Browse files Browse the repository at this point in the history
Refs: nodejs#43885

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: nodejs#44860
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
daeyeon authored and himself65 committed Mar 30, 2024
1 parent 8c8961d commit 6cf4503
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 21 deletions.
18 changes: 9 additions & 9 deletions doc/api/cli.md
Expand Up @@ -353,14 +353,6 @@ when `Error.stack` is accessed. If you access `Error.stack` frequently
in your application, take into account the performance implications
of `--enable-source-maps`.

### `--experimental-global-customevent`

<!-- YAML
added: v18.7.0
-->

Expose the [CustomEvent Web API][] on the global scope.

### `--experimental-global-webcrypto`

<!-- YAML
Expand Down Expand Up @@ -462,6 +454,14 @@ added: v18.0.0

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

### `--no-experimental-global-customevent`

<!-- YAML
added: REPLACEME
-->

Disable exposition of [CustomEvent Web API][] on the global scope.

### `--no-experimental-repl-await`

<!-- YAML
Expand Down Expand Up @@ -1966,7 +1966,6 @@ Node.js options that are allowed are:
* `--enable-source-maps`
* `--experimental-abortcontroller`
* `--experimental-default-type`
* `--experimental-global-customevent`
* `--experimental-global-webcrypto`
* `--experimental-import-meta-resolve`
* `--experimental-json-modules`
Expand Down Expand Up @@ -2000,6 +1999,7 @@ Node.js options that are allowed are:
* `--no-addons`
* `--no-deprecation`
* `--no-experimental-fetch`
* `--no-experimental-global-customevent`
* `--no-experimental-repl-await`
* `--no-extra-info-on-fatal-exception`
* `--no-force-async-hooks-checks`
Expand Down
9 changes: 7 additions & 2 deletions doc/api/globals.md
Expand Up @@ -390,10 +390,14 @@ only if the Node.js binary was compiled with including support for the

<!-- YAML
added: v18.7.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/44860
description: No longer behind `--experimental-global-customevent` CLI flag.
-->

> Stability: 1 - Experimental. Enable this API with the
> [`--experimental-global-customevent`][] CLI flag.
> Stability: 1 - Experimental. Disable this API with the
> [`--no-experimental-global-customevent`][] CLI flag.
<!-- type=global -->

Expand Down Expand Up @@ -888,6 +892,7 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
[`--experimental-global-customevent`]: cli.md#--experimental-global-customevent
[`--experimental-global-webcrypto`]: cli.md#--experimental-global-webcrypto
[`--no-experimental-fetch`]: cli.md#--no-experimental-fetch
[`--no-experimental-global-customevent`]: cli.md#--no-experimental-global-customevent
[`AbortController`]: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
[`ByteLengthQueuingStrategy`]: webstreams.md#class-bytelengthqueuingstrategy
[`CompressionStream`]: webstreams.md#class-compressionstream
Expand Down
6 changes: 3 additions & 3 deletions doc/node.1
Expand Up @@ -145,9 +145,6 @@ Interpret as either ES modules or CommonJS modules input via --eval or STDIN, wh
.js or extensionless files with no sibling or parent package.json;
.js or extensionless files whose nearest parent package.json lacks a "type" field, unless under node_modules.
.
.It Fl -experimental-global-customevent
Expose the CustomEvent on the global scope.
.
.It Fl -experimental-global-webcrypto
Expose the Web Crypto API on the global scope.
.
Expand All @@ -174,6 +171,9 @@ Enable code coverage in the test runner.
.It Fl -no-experimental-fetch
Disable experimental support for the Fetch API.
.
.It Fl -no-experimental-global-customevent
Disable exposition of the CustomEvent on the global scope.
.
.It Fl -no-experimental-repl-await
Disable top-level await keyword support in REPL.
.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process/pre_execution.js
Expand Up @@ -345,7 +345,7 @@ function setupCodeCoverage() {
// removed.
function setupCustomEvent() {
if (process.config.variables.node_no_browser_globals ||
!getOptionValue('--experimental-global-customevent')) {
getOptionValue('--no-experimental-global-customevent')) {
return;
}
const { CustomEvent } = require('internal/event_target');
Expand Down
3 changes: 2 additions & 1 deletion src/node_options.cc
Expand Up @@ -385,7 +385,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
AddOption("--experimental-global-customevent",
"expose experimental CustomEvent on the global scope",
&EnvironmentOptions::experimental_global_customevent,
kAllowedInEnvvar);
kAllowedInEnvironment,
true);
AddOption("--experimental-global-webcrypto",
"expose experimental Web Crypto API on the global scope",
&EnvironmentOptions::experimental_global_web_crypto,
Expand Down
2 changes: 1 addition & 1 deletion src/node_options.h
Expand Up @@ -111,7 +111,7 @@ class EnvironmentOptions : public Options {
std::string dns_result_order;
bool enable_source_maps = false;
bool experimental_fetch = true;
bool experimental_global_customevent = false;
bool experimental_global_customevent = true;
bool experimental_global_web_crypto = false;
bool experimental_https_modules = false;
std::string experimental_specifier_resolution;
Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-global-customevent-disabled.js
@@ -0,0 +1,7 @@
// Flags: --no-experimental-global-customevent
'use strict';

require('../common');
const { strictEqual } = require('node:assert');

strictEqual(typeof CustomEvent, 'undefined');
2 changes: 1 addition & 1 deletion test/parallel/test-global-customevent.js
@@ -1,4 +1,4 @@
// Flags: --experimental-global-customevent --expose-internals
// Flags: --expose-internals
'use strict';

require('../common');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-tab-complete.js
Expand Up @@ -405,7 +405,7 @@ putIn.run([
'var custom = "test";',
]);
testMe.complete('cus', common.mustCall(function(error, data) {
assert.deepStrictEqual(data, [['custom'], 'cus']);
assert.deepStrictEqual(data, [['CustomEvent', 'custom'], 'cus']);
}));

// Make sure tab completion doesn't crash REPL with half-baked proxy objects.
Expand Down
2 changes: 0 additions & 2 deletions test/wpt/test-events.js
Expand Up @@ -4,6 +4,4 @@ const { WPTRunner } = require('../common/wpt');

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

runner.setFlags(['--experimental-global-customevent']);

runner.runJsTests();

0 comments on commit 6cf4503

Please sign in to comment.