Skip to content

Commit b2b95eb

Browse files
benjamingrBenjamin Gruenbaum
authored and
Benjamin Gruenbaum
committed
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 07dcb75 commit b2b95eb

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
@@ -385,6 +385,7 @@ const ev = new Event('foo');
385385
{
386386
const target = new EventTarget();
387387
const event = new Event('foo');
388+
strictEqual(event.target, null);
388389
target.addEventListener('foo', common.mustCall((event) => {
389390
strictEqual(event.target, target);
390391
strictEqual(event.currentTarget, target);

0 commit comments

Comments
 (0)