Skip to content

Commit

Permalink
events: remove return value on addEventListener
Browse files Browse the repository at this point in the history
The `addEventListener()` should not return a value.

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: #37696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
jasnell authored and danielleadams committed Mar 16, 2021
1 parent 3e1a46a commit e384291
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion test/parallel/test-eventtarget-whatwg-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit e384291

Please sign in to comment.