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

addEventListener should support signal #1540

Open
e7h4n opened this issue Sep 16, 2024 · 0 comments
Open

addEventListener should support signal #1540

e7h4n opened this issue Sep 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@e7h4n
Copy link

e7h4n commented Sep 16, 2024

Describe the bug
According to the description in the document the addEventListener method should support the signal parameter. When the signal's AbortController aborts, all event listeners bound to that parameter should be unregistered.

To Reproduce

const ctrl = new AbortController()
const callbackCtrl = new AbortController()

ctrl.signal.addEventListener(
    'abort',
    () => {
        console.log('called')
    },
    {
        signal: callbackCtrl.signal,
    },
)

callbackCtrl.abort()
ctrl.abort()

Expected behavior
Nothing output in console

Actual situation
"called" is printed in console

Device:

  • OS: macOS
  • Browser: node
  • Version: 15.7.4

Additional context
vitest: 2.0.5

@e7h4n e7h4n added the bug Something isn't working label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant