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
Support AddEventListenerOptions #700
Labels
enhancement
New feature or request
Comments
btea
added a commit
to btea/happy-dom
that referenced
this issue
Feb 18, 2023
btea
added a commit
to btea/happy-dom
that referenced
this issue
Feb 18, 2023
capricorn86
added a commit
to btea/happy-dom
that referenced
this issue
Feb 19, 2023
…and options in separate objects.
capricorn86
added a commit
that referenced
this issue
Feb 19, 2023
#700@minor: Add event listener options.
Thanks for reporting @mrcaidev! 🙂 @btea has made a fix which adds support for the "once" option 🌟 You can read more about the release here: |
I will leave this open for the other options. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
EventTarget.addEventListener
can accept an optional third argumentoptions
, where developers can tweak the listener's behaviors.Sometimes we have to test these options, especially for library maintainers. But after I switched from
jsdom
tohappy-dom
today, I found my test suites broken, becauseoptions
are currently not supported inhappy-dom
.Describe the solution you'd like
It would be great if we can support passing
options
toEventTarget.addEventListeners
.Describe alternatives you've considered
I found that
happy-dom
has a light-weight implementation of event listeners, that is, to maintain a listeners array inEventTarget
, and call some of them conditionally.This is easy to understand and effective in most cases, but it may require more work, even some architectural changes, to implement event bubbling, which therefore makes it a little hard to implement
options.capture
.But maybe we can implement some relatively easy ones first, e.g.
options.once
.Additional context
None.
The text was updated successfully, but these errors were encountered: