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

Add support for once #40

Merged
merged 3 commits into from
Apr 22, 2023
Merged

Add support for once #40

merged 3 commits into from
Apr 22, 2023

Conversation

fregante
Copy link
Owner

@fregante fregante commented Apr 22, 2023

cc @stof

Matches the native once behavior:

document.addEventListener('click', console.log, {once: true})
document.addEventListener('click', console.log)
// The second one is ignored, the listener is called once
document.addEventListener('click', console.log)
document.addEventListener('click', console.log, {once: true})
// The second one is ignored, the listener is called without limits

@fregante fregante marked this pull request as ready for review April 22, 2023 04:00
This was referenced Apr 22, 2023
@fregante
Copy link
Owner Author

I think this currently doesn't properly support arrays of elements, like:

delegate([a, div], 'span', 'click', console.log, {once: true})

But I'll merge it for now and open an issue, it's a rare usage and probably should be dropped altogether.

@fregante fregante merged commit 39dcce7 into main Apr 22, 2023
@fregante fregante deleted the once branch April 22, 2023 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for {once: true}
1 participant