Skip to content

Commit 0a2edb5

Browse files
Benjamin GruenbaumBenjamin Gruenbaum
Benjamin Gruenbaum
authored and
Benjamin Gruenbaum
committed
events: deal with no arguments case
1 parent 2935f72 commit 0a2edb5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/internal/event_target.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Event {
5050
this.#cancelable = !!cancelable;
5151
this.#bubbles = !!bubbles;
5252
this.#composed = !!composed;
53-
this.#type = String(type);
53+
this.#type = '' + type;
5454
// isTrusted is special (LegacyUnforgeable)
5555
Object.defineProperty(this, 'isTrusted', {
5656
get() { return false; },

test/parallel/test-eventtarget.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ok(EventTarget);
4949

5050
ev.preventDefault();
5151
strictEqual(ev.defaultPrevented, true);
52+
throws(() => new Event(Symbol()), TypeError);
5253
}
5354
{
5455
const ev = new Event('foo');

0 commit comments

Comments
 (0)