Skip to content

Commit 2738e94

Browse files
committed
events: set target property to null
1 parent 3128915 commit 2738e94

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
@@ -60,6 +60,7 @@ class Event {
6060
enumerable: true,
6161
configurable: false
6262
});
63+
this[kTarget] = null;
6364
}
6465

6566
[customInspectSymbol](depth, options) {
@@ -241,7 +242,7 @@ class EventTarget {
241242
}
242243

243244
if (this.#emitting.has(event.type) ||
244-
event[kTarget] !== undefined) {
245+
event[kTarget] !== null) {
245246
throw new ERR_EVENT_RECURSION(event.type);
246247
}
247248

test/parallel/test-eventtarget.js

+1
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ ok(EventTarget);
370370
{
371371
const target = new EventTarget();
372372
const event = new Event('foo');
373+
strictEqual(event.target, null);
373374
target.addEventListener('foo', common.mustCall((event) => {
374375
strictEqual(event.target, target);
375376
strictEqual(event.currentTarget, target);

0 commit comments

Comments
 (0)