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

feature: allow on: event listeners on <Component/> nodes #448

Merged
merged 1 commit into from
Feb 3, 2023

Conversation

gbj
Copy link
Collaborator

@gbj gbj commented Feb 3, 2023

No description provided.

@gbj gbj merged commit bb9df89 into main Feb 3, 2023
@gbj gbj deleted the component-event-listeners branch February 3, 2023 04:24
@ModProg
Copy link
Contributor

ModProg commented Feb 3, 2023

One thing that I noticed is, that if you register an event listener on a component that will override the internal event listener if they happen to apply to the same element:

Component = <input on:input= |_| do_some_thing()/>
Callsite: <Component on:input=|_| do_some_thing_else()/>

do_some_thing will never be called, but:

Component = <div><input on:input= |_| do_some_thing()/></div>
Callsite: <Component on:input=|_| do_some_thing_else()/>

works as expected, and both do_some_thing and do_some_thing_else are called.

@gbj
Copy link
Collaborator Author

gbj commented Feb 3, 2023

Yeah that makes sense to me, as I don't think we currently support adding multiple of the same event listener:
<input on:input= |_| do_some_thing() on:input=|_| do_some_other_thing()/>

Maybe we should -- if this would be helpful for your use case you could open a feature request issue to be able to add multiple event listeners of the same type to an element.

Components don't "exist" in any sense, so there's nothing to attach a listener to other than the elements.

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.

None yet

2 participants