Skip to content

fix: ensure element effects are executed in the correct order #14038

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

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Oct 30, 2024

This PR changes the ordering of event handlers, bindings and actions so they're now created in order of usage – which means that they fall in line with the logic and control-flow ordering too.

Copy link

changeset-bot bot commented Oct 30, 2024

🦋 Changeset detected

Latest commit: de03883

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Oct 30, 2024

pnpm add https://pkg.pr.new/svelte@14038

commit: de03883

Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — does this necessitate any changes in the docs, or no because it only affects the relative ordering of bindings and actions?

From https://svelte.dev/docs/svelte/bind:

Svelte creates an event listener that updates the bound value. If an element already has a listener for the same event, that listener will be fired before the bound value is updated.

@trueadm
Copy link
Contributor Author

trueadm commented Oct 30, 2024

I don't believe it does, that part of the docs still holds true.

@trueadm trueadm merged commit 253d01e into main Oct 30, 2024
10 checks passed
@trueadm trueadm deleted the better-element-effects branch October 30, 2024 16:27
@github-actions github-actions bot mentioned this pull request Oct 30, 2024
);
if (has_action_directive) {
context.state.init.push(
b.stmt(has_action_directive ? b.call('$.effect', b.thunk(call)) : call)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no big deal but seemed no longer necessary to check again.

Suggested change
b.stmt(has_action_directive ? b.call('$.effect', b.thunk(call)) : call)
b.stmt(b.call('$.effect', b.thunk(call)))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this was updated

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.

3 participants