fix: run event attributes after binding event listeners #11230
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By running the event listener logic inside an effect on the first run we guarantee that they're attached after binding listeners.
Fixes #11138
Fixes #11160
In contrast to #11229 this is a hilariously simple change, though it does not ensure that event attributes run after event listeners added inside action attributes. If we wanted that, we would need to return the list of events from the function, and then run them in an effect we can place at the very end of the current block. Should we that or not?
While working on this I noticed two things:
[{ foo: .. }, rest, { bar: .. }]
we should be able to do{ foo: .., ...rest, bar: .. }
Both can happen in a followup PR or as part of this one, depending on what the response here is by tomorrow.Added both these improvements.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint