events: set target property to null

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Benjamin Gruenbaum authored and James M Snell committed 2020-06-05 16:27:04 -07:00
1 parent 236237829b
commit 1969ada982
2 files changed
+3 -1

No files matched your search

+2 -1
View File
@@ -64,6 +64,7 @@ class Event {
enumerable: true,
configurable: false
});
this[kTarget] = null;
}
[customInspectSymbol](depth, options) {
@@ -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);
}
+1
View File
@@ -379,6 +379,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);