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: true} #30

Closed
fregante opened this issue Jun 25, 2022 · 2 comments · Fixed by #40
Closed

Add support for {once: true} #30

fregante opened this issue Jun 25, 2022 · 2 comments · Fixed by #40
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@fregante
Copy link
Owner

delegate-it/index.ts

Lines 117 to 118 in 719e834

// Drop unsupported `once` option https://github.com/fregante/delegate-it/pull/28#discussion_r863467939
delete listenerOptions.once;

@stof
Copy link
Contributor

stof commented Jul 8, 2022

Even if you support it in the delegate-it API, you will still probably need to drop it from the native listener options due to sharing the native listener (see the ledger system)

@fregante
Copy link
Owner Author

fregante commented Jul 8, 2022

Most definitely, even regardless of ledger, our listener is called many times so with once: true it would be removed before calling the user’s callback

delegate-it/index.ts

Lines 152 to 157 in 00b85c8

const listenerFn = (event: Event): void => {
const delegateTarget = safeClosest(event, selector);
if (delegateTarget) {
const delegateEvent = Object.assign(event, {delegateTarget});
callback.call(baseElement, delegateEvent as DelegateEvent<GlobalEventHandlersEventMap[TEventType], TElement>);
}

@fregante fregante added enhancement New feature or request help wanted Extra attention is needed labels Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants