Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit be2fe4b

Browse filesBrowse files
KhafraDevtargos
authored andcommitted
events: allow null/undefined eventInitDict
PR-URL: #54643 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f7c3b03 commit be2fe4b
Copy full SHA for be2fe4b

File tree

Expand file treeCollapse file tree

2 files changed

+12
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-6
lines changed
Open diff view settings
Collapse file

‎lib/internal/event_target.js‎

Copy file name to clipboardExpand all lines: lib/internal/event_target.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ class Event {
111111
* composed?: boolean,
112112
* }} [options]
113113
*/
114-
constructor(type, options = kEmptyObject) {
114+
constructor(type, options = undefined) {
115115
if (arguments.length === 0)
116116
throw new ERR_MISSING_ARGS('type');
117-
validateObject(options, 'options');
118-
const { bubbles, cancelable, composed } = options;
119-
this.#cancelable = !!cancelable;
120-
this.#bubbles = !!bubbles;
121-
this.#composed = !!composed;
117+
if (options != null)
118+
validateObject(options, 'options');
119+
this.#bubbles = !!options?.bubbles;
120+
this.#cancelable = !!options?.cancelable;
121+
this.#composed = !!options?.composed;
122122

123123
this[kType] = `${type}`;
124124
if (options?.[kTrustEvent]) {
Collapse file

‎test/parallel/test-eventtarget.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eventtarget.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,3 +747,9 @@ let asyncTest = Promise.resolve();
747747
event.cancelBubble = true;
748748
strictEqual(event.cancelBubble, true);
749749
}
750+
751+
{
752+
// A null eventInitDict should not throw an error.
753+
new Event('', null);
754+
new Event('', undefined);
755+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.