events: deal with Symbol() passed to event constructor

PR-URL: https://github.com/nodejs/node/pull/33612
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Benjamin Gruenbaum authored and James M Snell committed 2020-06-03 14:19:25 -07:00
1 parent 673f49ac94
commit 3a7a5d7e62
2 files changed
+2 -1

No files matched your search

+1 -1
View File
@@ -50,7 +50,7 @@ class Event {
this.#cancelable = !!cancelable;
this.#bubbles = !!bubbles;
this.#composed = !!composed;
this.#type = String(type);
this.#type = `${type}`;
// isTrusted is special (LegacyUnforgeable)
Object.defineProperty(this, 'isTrusted', {
get() { return false; },
+1
View File
@@ -49,6 +49,7 @@ ok(EventTarget);
ev.preventDefault();
strictEqual(ev.defaultPrevented, true);
throws(() => new Event(Symbol()), TypeError);
}
{
const ev = new Event('foo');