-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: send $effect.pending
count to the correct boundary
#16732
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
5 commits
Select commit
Hold shift + click to select a range
128e158
fix: send `$effect.pending` count to the correct boundary
Rich-Harris 95400b5
make boundary.pending private, use boundary.is_pending consistently
Rich-Harris 26e4a4c
move error to correct place
Rich-Harris 8418298
we need that error
Rich-Harris 545903f
update JSDoc
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: send `$effect.pending` count to the correct boundary |
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
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
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
95 changes: 95 additions & 0 deletions
95
packages/svelte/tests/runtime-runes/samples/async-effect-pending-nested/_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,95 @@ | ||
import { tick } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
async test({ assert, target }) { | ||
const [increment, shift] = target.querySelectorAll('button'); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<button>increment</button> | ||
<button>shift</button> | ||
<p>loading...</p> | ||
` | ||
); | ||
|
||
shift.click(); | ||
shift.click(); | ||
shift.click(); | ||
|
||
await tick(); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<button>increment</button> | ||
<button>shift</button> | ||
<p>0</p> | ||
<p>0</p> | ||
<p>0</p> | ||
<p>inner pending: 0</p> | ||
<p>outer pending: 0</p> | ||
` | ||
); | ||
|
||
increment.click(); | ||
await tick(); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<button>increment</button> | ||
<button>shift</button> | ||
<p>0</p> | ||
<p>0</p> | ||
<p>0</p> | ||
<p>inner pending: 3</p> | ||
<p>outer pending: 0</p> | ||
` | ||
); | ||
|
||
shift.click(); | ||
await tick(); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<button>increment</button> | ||
<button>shift</button> | ||
<p>0</p> | ||
<p>0</p> | ||
<p>0</p> | ||
<p>inner pending: 2</p> | ||
<p>outer pending: 0</p> | ||
` | ||
); | ||
|
||
shift.click(); | ||
await tick(); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<button>increment</button> | ||
<button>shift</button> | ||
<p>0</p> | ||
<p>0</p> | ||
<p>0</p> | ||
<p>inner pending: 1</p> | ||
<p>outer pending: 0</p> | ||
` | ||
); | ||
|
||
shift.click(); | ||
await tick(); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<button>increment</button> | ||
<button>shift</button> | ||
<p>1</p> | ||
<p>1</p> | ||
<p>1</p> | ||
<p>inner pending: 0</p> | ||
<p>outer pending: 0</p> | ||
` | ||
); | ||
} | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/svelte/tests/runtime-runes/samples/async-effect-pending-nested/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,34 @@ | ||
<script> | ||
let value = $state(0); | ||
let deferreds = []; | ||
|
||
function push(value) { | ||
const deferred = Promise.withResolvers(); | ||
deferreds.push({ value, deferred }); | ||
return deferred.promise; | ||
} | ||
|
||
function shift() { | ||
const d = deferreds.shift(); | ||
d?.deferred.resolve(d.value); | ||
} | ||
</script> | ||
|
||
<button onclick={() => value++}>increment</button> | ||
<button onclick={() => shift()}>shift</button> | ||
|
||
<svelte:boundary> | ||
<svelte:boundary> | ||
<p>{await push(value)}</p> | ||
<p>{await push(value)}</p> | ||
<p>{await push(value)}</p> | ||
<p>inner pending: {$effect.pending()}</p> | ||
</svelte:boundary> | ||
<p>outer pending: {$effect.pending()}</p> | ||
|
||
{#snippet pending()} | ||
<p>loading...</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.
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.
JSDoc to not call this inside class
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.
done