-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Svelte 5: Actions and on: directives don't respect the order they are listed #11516
Comments
In the generated code, I do see these in order $.action(button, ($$node) => action($$node));
$.event("click", button, handler, false); so I'm assuming that |
Conversely, when I'm using I'm guessing this is expected, though? Is this just a result of event delegation? |
Yes it's a result of event delegation, with #11435 as a proposal to possibly fix this. The reason they run out of order is that action functions are executed in an effect, because else the dom isn't attached yet and certain stuff doesn't work correctly (I don't remember the details, if I do we should document this in the code). I'm not sure how to best fix this, if we want to fix this. Put listeners inside an effect, too? Bindings are already inside effects AFAIK so that order is preserved. |
Describe the bug
In Svelte 4, putting a
use:
action followed by anon:
event handler on an element would first attach the action and then attach the event handler. In Svelte 5, it looks like event handlers are attached before the actions, regardless of the order they are specified on the element.Reproduction
https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACnWQQW7DIBBFr4LY2JaidE-cSF101xvUXRAYp6h4xoIhUmX57gWHJN10A_z5_DcMixydhyjVxyJRTyCVfJ1nuZP8MxcRr-AZso6UgimVPprgZj4NOPCY0LAjFHrbWiQLnViKNXARe23t2xWQ311kQAhtY7wz381OtJ04noQhjORh7-lSLTEGmipQQMmKL43WQ2i67lDQa17-Nq92--j8HzTAJXkdnrw7rn95DoX9OTFnbIqg6jMI1YY5LjW6buPfLpb47ZSL-acmsm50YKXikGD9XH8B9L2B8mQBAAA=
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: