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

Support AddEventListenerOptions #700

Open
mrcaidev opened this issue Jan 26, 2023 · 2 comments
Open

Support AddEventListenerOptions #700

mrcaidev opened this issue Jan 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@mrcaidev
Copy link

mrcaidev commented Jan 26, 2023

Is your feature request related to a problem? Please describe.

EventTarget.addEventListener can accept an optional third argument options, 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 to happy-dom today, I found my test suites broken, because options are currently not supported in happy-dom.

Describe the solution you'd like

It would be great if we can support passing options to EventTarget.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 in EventTarget, 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.

@mrcaidev mrcaidev added the enhancement New feature or request label Jan 26, 2023
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
capricorn86 added a commit that referenced this issue Feb 19, 2023
@capricorn86
Copy link
Owner

Thanks for reporting @mrcaidev! 🙂

@btea has made a fix which adds support for the "once" option 🌟

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v8.6.0

@capricorn86
Copy link
Owner

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
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants