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

fix: wrap each block expression in derived to encapsulte effects #14967

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Jan 9, 2025

Fixes #14961.

We have logic in the each block today that assumes that the child effects of an each block effect are always the entries of the each block. This is not correct – as the expression used to get the collection for the each block might also create its own effects. Previously, we'd override the effects created from get_collection and it would cause a bunch of issues.

To avoid this, we can wrap the collection expression in a derived that enables us to instead put the effects associated with that collection with the derived rather than the each block effect.

Copy link

changeset-bot bot commented Jan 9, 2025

🦋 Changeset detected

Latest commit: dcd124b

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

@Rich-Harris
Copy link
Member

preview: https://svelte-dev-git-preview-svelte-14967-svelte.vercel.app/

this is an automated message

Copy link
Contributor

github-actions bot commented Jan 9, 2025

Playground

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

@trueadm trueadm marked this pull request as ready for review January 9, 2025 21:33
@trueadm trueadm merged commit dbe5818 into main Jan 10, 2025
11 checks passed
@trueadm trueadm deleted the fix-each-block-effects branch January 10, 2025 01:14
@github-actions github-actions bot mentioned this pull request Jan 10, 2025
dummdidumm added a commit that referenced this pull request Jan 13, 2025
closes #14991 - at least to the extent possible

Also adjusts a comment which a) did not hint at why it's needed in the first place (was added in #14967) b) sounded like we could change that in the future, but we can't, because people will always have the ability to trigger reactivity through other means without changing the array reference
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.

Strange cleanup bug when using {#each} block
2 participants