Skip to content

Commit 2e6ecea

Browse files
benjamingrcodebytere
authored andcommitted
events: set target property to null
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]>
1 parent bc2e821 commit 2e6ecea

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/internal/event_target.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Event {
6464
enumerable: true,
6565
configurable: false
6666
});
67+
this[kTarget] = null;
6768
}
6869

6970
[customInspectSymbol](depth, options) {
@@ -245,7 +246,7 @@ class EventTarget {
245246
}
246247

247248
if (this.#emitting.has(event.type) ||
248-
event[kTarget] !== undefined) {
249+
event[kTarget] !== null) {
249250
throw new ERR_EVENT_RECURSION(event.type);
250251
}
251252

test/parallel/test-eventtarget.js

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ ok(EventTarget);
379379
{
380380
const target = new EventTarget();
381381
const event = new Event('foo');
382+
strictEqual(event.target, null);
382383
target.addEventListener('foo', common.mustCall((event) => {
383384
strictEqual(event.target, target);
384385
strictEqual(event.currentTarget, target);

0 commit comments

Comments
 (0)