Skip to content

Commit

Permalink
events: add initEvent to Event
Browse files Browse the repository at this point in the history
  • Loading branch information
deokjinkim committed Jan 7, 2023
1 parent 6763932 commit f5974f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
18 changes: 18 additions & 0 deletions lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,23 @@ class Event {
this[kIsBeingDispatched] = false;
}

/**
* @param {string} type
* @param {boolean} [bubbles]
* @param {boolean} [cancelable]
*/
initEvent(type, bubbles = false, cancelable = false) {
if (arguments.length === 0)
throw new ERR_MISSING_ARGS('type');

if (this[kIsBeingDispatched]) {
return;
}
this[kType] = `${type}`;
this.#bubbles = !!bubbles;
this.#cancelable = !!cancelable;
}

[customInspectSymbol](depth, options) {
if (!isEvent(this))
throw new ERR_INVALID_THIS('Event');
Expand Down Expand Up @@ -307,6 +324,7 @@ ObjectDefineProperties(
configurable: true,
value: 'Event',
},
initEvent: kEnumerableProperty,
stopImmediatePropagation: kEnumerableProperty,
preventDefault: kEnumerableProperty,
target: kEnumerableProperty,
Expand Down
8 changes: 0 additions & 8 deletions test/wpt/status/dom/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
]
}
},
"Event-constructors.any.js": {
"fail": {
"expected": [
"Untitled 2",
"Untitled 3"
]
}
},
"Event-dispatch-listener-order.window.js": {
"skip": "document is not defined"
},
Expand Down

0 comments on commit f5974f6

Please sign in to comment.