mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
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:
1 parent
236237829b
commit
1969ada982
2 files changed
+3
-1
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user