-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Multiple event listeners per node #2688
Comments
Hi @LostKobrakai! Could you not do something like the following: <script>
import Component from './Component.svelte';
function onInput(event) {
console.log(event)
}
</script>
<Component let:listener>
<input on:input={e => { listener(e); onInput(e); }} />
</Component> |
Sure, but I don't see much reason against supporting the notation I proposed especially given it already works with different modifiers. It currently seems to be more of an accidental restriction of the unique attributes check. Having the ability to attach multiple handlers is imho more in line with using multiple |
This is now merged. |
It would be quite neat to allow for multiple event listeners per node even if they're of the same type. It already works when one is using a modifier and the other doesn't, but otherwise there will be an error about
Attributes need to be unique
. I've already looked into the code and it could be changed by moving the check for unique attributes a few lines lower and giving it an extra case for EventHandlers. Tests are still green after the change.The text was updated successfully, but these errors were encountered: