Skip to content

Commit

Permalink
events: set target property to null
Browse files Browse the repository at this point in the history
PR-URL: #33615
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
  • Loading branch information
benjamingr authored and codebytere committed Jun 18, 2020
1 parent bc2e821 commit 2e6ecea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Event {
enumerable: true,
configurable: false
});
this[kTarget] = null;
}

[customInspectSymbol](depth, options) {
Expand Down Expand Up @@ -245,7 +246,7 @@ class EventTarget {
}

if (this.#emitting.has(event.type) ||
event[kTarget] !== undefined) {
event[kTarget] !== null) {
throw new ERR_EVENT_RECURSION(event.type);
}

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-eventtarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ ok(EventTarget);
{
const target = new EventTarget();
const event = new Event('foo');
strictEqual(event.target, null);
target.addEventListener('foo', common.mustCall((event) => {
strictEqual(event.target, target);
strictEqual(event.currentTarget, target);
Expand Down

0 comments on commit 2e6ecea

Please sign in to comment.