mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
events: allow null/undefined eventInitDict
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
d473606040
commit
a9081b5391
@ -111,14 +111,14 @@ class Event {
|
||||
* composed?: boolean,
|
||||
* }} [options]
|
||||
*/
|
||||
constructor(type, options = kEmptyObject) {
|
||||
constructor(type, options = undefined) {
|
||||
if (arguments.length === 0)
|
||||
throw new ERR_MISSING_ARGS('type');
|
||||
validateObject(options, 'options');
|
||||
const { bubbles, cancelable, composed } = options;
|
||||
this.#cancelable = !!cancelable;
|
||||
this.#bubbles = !!bubbles;
|
||||
this.#composed = !!composed;
|
||||
if (options != null)
|
||||
validateObject(options, 'options');
|
||||
this.#bubbles = !!options?.bubbles;
|
||||
this.#cancelable = !!options?.cancelable;
|
||||
this.#composed = !!options?.composed;
|
||||
|
||||
this[kType] = `${type}`;
|
||||
if (options?.[kTrustEvent]) {
|
||||
|
@ -747,3 +747,9 @@ let asyncTest = Promise.resolve();
|
||||
event.cancelBubble = true;
|
||||
strictEqual(event.cancelBubble, true);
|
||||
}
|
||||
|
||||
{
|
||||
// A null eventInitDict should not throw an error.
|
||||
new Event('', null);
|
||||
new Event('', undefined);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user