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 <[email protected]>

PR-URL: #37696
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
jasnell authored and danielleadams committed Mar 16, 2021
1 parent efd14a9 commit 3acba1d
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 3acba1d

Please sign in to comment.