Skip to content

Commit

Permalink
events: set target property to null
Browse files Browse the repository at this point in the history
PR-URL: nodejs#33615
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
  • Loading branch information
benjamingr authored and Benjamin Gruenbaum committed May 31, 2020
1 parent 07dcb75 commit b2b95eb
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 @@ -385,6 +385,7 @@ const ev = new Event('foo');
{
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 b2b95eb

Please sign in to comment.