Skip to content

Commit e7bce2e

Browse files
Benjamin Gruenbaumcodebytere
Benjamin Gruenbaum
authored andcommittedJun 18, 2020
events: deal with Symbol() passed to event constructor
PR-URL: #33612 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 21f1e64 commit e7bce2e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed
 

‎lib/internal/event_target.js

+1-1
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

+1
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)
Please sign in to comment.