-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix: run effects in pending snippets #17719
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
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bfec966
failing test
Rich-Harris 1b643dc
tweak
Rich-Harris ab65939
tweak
Rich-Harris 7d289ce
tweak
Rich-Harris 31845b7
tweak
Rich-Harris 27c8b84
tweak
Rich-Harris 8417c2d
unused
Rich-Harris 0680cfb
unused
Rich-Harris 9510fca
WIP move .b flag onto main effect
Rich-Harris 032cb22
WIP
Rich-Harris 2efdb4c
fix
Rich-Harris e154c3c
simplify
Rich-Harris 876d0b3
reverse condition
Rich-Harris 2bf10f2
changeset
Rich-Harris d6a3282
unused
Rich-Harris 4a8fd1f
tidy
Rich-Harris 3a3d8cf
simplify
Rich-Harris 02a8f39
Update packages/svelte/src/internal/client/dom/blocks/boundary.js
dummdidumm 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: run effects in pending snippets |
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
38 changes: 38 additions & 0 deletions
38
packages/svelte/tests/runtime-runes/samples/async-boundary-pending-live/_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,38 @@ | ||
| import { tick } from 'svelte'; | ||
| import { test } from '../../test'; | ||
|
|
||
| export default test({ | ||
| html: ` | ||
| <button>increment</button> | ||
| <button>shift</button> | ||
| <p>0</p> | ||
| `, | ||
|
|
||
| async test({ assert, target }) { | ||
| const [increment, shift] = target.querySelectorAll('button'); | ||
|
|
||
| increment.click(); | ||
| await tick(); | ||
|
|
||
| assert.htmlEqual( | ||
| target.innerHTML, | ||
| ` | ||
| <button>increment</button> | ||
| <button>shift</button> | ||
| <p>1</p> | ||
| ` | ||
| ); | ||
|
|
||
| shift.click(); | ||
| await tick(); | ||
|
|
||
| assert.htmlEqual( | ||
| target.innerHTML, | ||
| ` | ||
| <button>increment</button> | ||
| <button>shift</button> | ||
| <p>resolved</p> | ||
| ` | ||
| ); | ||
| } | ||
| }); |
31 changes: 31 additions & 0 deletions
31
packages/svelte/tests/runtime-runes/samples/async-boundary-pending-live/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,31 @@ | ||
| <script> | ||
| let resolvers = []; | ||
|
|
||
| function push(value) { | ||
| const deferred = Promise.withResolvers(); | ||
| resolvers.push(() => deferred.resolve(value)); | ||
| return deferred.promise; | ||
| } | ||
|
|
||
| function shift() { | ||
| resolvers.shift()?.(); | ||
| } | ||
|
|
||
| let count = $state(0); | ||
| </script> | ||
|
|
||
| <button onclick={() => count += 1}> | ||
| increment | ||
| </button> | ||
|
|
||
| <button onclick={shift}> | ||
| shift | ||
| </button> | ||
|
|
||
| <svelte:boundary> | ||
| <p>{await push('resolved')}</p> | ||
|
|
||
| {#snippet pending()} | ||
| <p>{count}</p> | ||
| {/snippet} | ||
| </svelte:boundary> |
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.
Uh oh!
There was an error while loading. Please reload this page.