From 453df77f99cb53e75930fea3dfe18ebeecb977aa Mon Sep 17 00:00:00 2001 From: Khafra Date: Thu, 29 Aug 2024 16:21:10 -0400 Subject: [PATCH] events: return `currentTarget` when dispatching PR-URL: https://github.com/nodejs/node/pull/54642 Reviewed-By: Yagiz Nizipli Reviewed-By: Matteo Collina Reviewed-By: Mattias Buelens Reviewed-By: Benjamin Gruenbaum Reviewed-By: Ethan Arrowood Reviewed-By: Chemi Atlow Reviewed-By: James M Snell --- lib/internal/event_target.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 73d8c12ee7ff9b..cfd3a4922e62ad 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -200,7 +200,7 @@ class Event { get currentTarget() { if (!isEvent(this)) throw new ERR_INVALID_THIS('Event'); - return this[kTarget]; + return this[kIsBeingDispatched] ? this[kTarget] : null; } /**