Skip to content
Permalink
Browse files
events: fix event-target enumerable keys
PR-URL: #33616
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
benjamingr authored and codebytere committed Jun 18, 2020
1 parent f3d0d30 commit 2a29ced050539438c17bc4011c05cc5c75546d49
Showing with 11 additions and 2 deletions.
  1. +7 −1 lib/internal/event_target.js
  2. +4 −1 test/parallel/test-eventtarget.js
@@ -51,6 +51,13 @@ class Event {
this.#bubbles = !!bubbles;
this.#composed = !!composed;
this.#type = String(type);
// isTrusted is special (LegacyUnforgeable)
Object.defineProperty(this, 'isTrusted', {
get() { return false; },
set(ignoredValue) { return false; },
enumerable: true,
configurable: false
});
}

[customInspectSymbol](depth, options) {
@@ -99,7 +106,6 @@ class Event {
get returnValue() { return !this.defaultPrevented; }
get bubbles() { return this.#bubbles; }
get composed() { return this.#composed; }
get isTrusted() { return false; }
get eventPhase() {
return this[kTarget] ? 2 : 0; // Equivalent to AT_TARGET or NONE
}
@@ -50,7 +50,10 @@ ok(EventTarget);
ev.preventDefault();
strictEqual(ev.defaultPrevented, true);
}

{
const ev = new Event('foo');
deepStrictEqual(Object.keys(ev), ['isTrusted']);
}
{
const eventTarget = new EventTarget();

0 comments on commit 2a29ced

Please sign in to comment.