From 2e6eceac5c37586ccf108a23734c70bb6acf990c Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Thu, 28 May 2020 17:43:11 +0300 Subject: [PATCH] events: set target property to null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33615 Reviewed-By: Ruben Bridgewater Reviewed-By: Zeyu Yang Reviewed-By: James M Snell Reviewed-By: Juan José Arboleda --- lib/internal/event_target.js | 3 ++- test/parallel/test-eventtarget.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 47f7b1d592a1c7..df25200f1b09d8 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -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); } diff --git a/test/parallel/test-eventtarget.js b/test/parallel/test-eventtarget.js index cf52030aee5a05..8d4be41df55c73 100644 --- a/test/parallel/test-eventtarget.js +++ b/test/parallel/test-eventtarget.js @@ -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);