Skip to content

Commit

Permalink
events: set target property to null
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamingr committed Jun 5, 2020
1 parent 3128915 commit 2738e94
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 @@ -60,6 +60,7 @@ class Event {
enumerable: true,
configurable: false
});
this[kTarget] = null;
}

[customInspectSymbol](depth, options) {
Expand Down Expand Up @@ -241,7 +242,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 @@ -370,6 +370,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 2738e94

Please sign in to comment.