Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event: remove return value on addEventListener #37696

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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