-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix: maintain correct linked list of effects when updating each blocks #17191
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
+104
−26
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f5f23e3
fix: maintain correct linked list of effects when updating each blocks
Rich-Harris 111d48e
working
Rich-Harris 048a200
tidy up
Rich-Harris 745ed58
changeset
Rich-Harris 216e9cc
remove unnecessary assignment, add comment explaining unidirectionality
Rich-Harris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'svelte': patch | ||
| --- | ||
|
|
||
| fix: maintain correct linked list of effects when updating each blocks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/svelte/tests/runtime-runes/samples/each-effect-linking/_config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { tick } from 'svelte'; | ||
| import { test } from '../../test'; | ||
|
|
||
| export default test({ | ||
| async test({ assert, target }) { | ||
| const [step_back, step_forward, jump_back, jump_forward] = target.querySelectorAll('button'); | ||
| const [div] = target.querySelectorAll('div'); | ||
|
|
||
| step_back.click(); | ||
| await tick(); | ||
|
|
||
| step_forward.click(); | ||
| await tick(); | ||
|
|
||
| step_forward.click(); | ||
| await tick(); | ||
|
|
||
| // if the effects get linked in a circle, we will never get here | ||
| assert.htmlEqual(div.innerHTML, '<p>5</p><p>6</p><p>7</p>'); | ||
|
|
||
| jump_forward.click(); | ||
| await tick(); | ||
|
|
||
| step_forward.click(); | ||
| await tick(); | ||
|
|
||
| step_forward.click(); | ||
| await tick(); | ||
|
|
||
| assert.htmlEqual(div.innerHTML, '<p>12</p><p>13</p><p>14</p>'); | ||
| } | ||
| }); |
33 changes: 33 additions & 0 deletions
33
packages/svelte/tests/runtime-runes/samples/each-effect-linking/main.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <script lang="ts"> | ||
| let items = $state([4, 5, 6]); | ||
| </script> | ||
|
|
||
| <button onclick={() => { | ||
| items = items.map((n) => n - 1); | ||
| }}> | ||
| step back | ||
| </button> | ||
|
|
||
| <button onclick={() => { | ||
| items = items.map((n) => n + 1); | ||
| }}> | ||
| step forward | ||
| </button> | ||
|
|
||
| <button onclick={() => { | ||
| items = items.map((n) => n - 5); | ||
| }}> | ||
| jump back | ||
| </button> | ||
|
|
||
| <button onclick={() => { | ||
| items = items.map((n) => n + 5); | ||
| }}> | ||
| jump forward | ||
| </button> | ||
|
|
||
| <div> | ||
| {#each items as item (item)} | ||
| <p>{item}</p> | ||
| {/each} | ||
| </div> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for clarification: This now keeps a link to the offscreen effects such that they are still connected precisely because prev.e.next is no longer set to null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly — all effects are linked whether they're onscreen or offscreen, such that updates correctly flow through to offscreen effects as well as onscreen ones