From 3acba1d519030157f34d1fc7f65e1d3f03f6548e Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 10 Mar 2021 09:32:53 -0800 Subject: [PATCH] events: remove return value on addEventListener MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `addEventListener()` should not return a value. Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/37696 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Gerhard Stöbich Reviewed-By: Trivikram Kamat Reviewed-By: Luigi Pinca --- lib/internal/event_target.js | 2 +- test/parallel/test-eventtarget-whatwg-signal.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 9dfbb8f9c4a5ce..8a20185b85be56 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -329,7 +329,7 @@ class EventTarget { if (signal) { if (signal.aborted) { - return false; + return; } // TODO(benjamingr) make this weak somehow? ideally the signal would // not prevent the event target from GC. diff --git a/test/parallel/test-eventtarget-whatwg-signal.js b/test/parallel/test-eventtarget-whatwg-signal.js index 8573d2b4aea5bb..dfe5810180d90e 100644 --- a/test/parallel/test-eventtarget-whatwg-signal.js +++ b/test/parallel/test-eventtarget-whatwg-signal.js @@ -25,7 +25,11 @@ const { controller.abort(); et.dispatchEvent(new Event('test')); strictEqual(count, 2, 'Aborting on the controller removes the listener'); - et.addEventListener('test', handler, { signal: controller.signal }); + // See: https://github.com/nodejs/node/pull/37696 , adding an event listener + // should always return undefined. + strictEqual( + et.addEventListener('test', handler, { signal: controller.signal }), + undefined); et.dispatchEvent(new Event('test')); strictEqual(count, 2, 'Passing an aborted signal never adds the handler'); }