-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid flushing sync with $inspect (#13239)
* fix: avoid flushing sync with $inspect * add test
- Loading branch information
Showing
4 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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: avoid flushing sync with $inspect |
This file contains 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
26 changes: 26 additions & 0 deletions
26
packages/svelte/tests/runtime-runes/samples/effect-order-3/_config.js
This file contains 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,26 @@ | ||
import { test } from '../../test'; | ||
import { flushSync } from 'svelte'; | ||
|
||
export default test({ | ||
async test({ assert, target, logs }) { | ||
const [b1] = target.querySelectorAll('button'); | ||
flushSync(() => { | ||
b1.click(); | ||
}); | ||
flushSync(() => { | ||
b1.click(); | ||
}); | ||
assert.deepEqual(logs, [ | ||
'effect', | ||
0, | ||
'in-increment', | ||
1, | ||
'effect', | ||
1, | ||
'in-increment', | ||
2, | ||
'effect', | ||
2 | ||
]); | ||
} | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/svelte/tests/runtime-runes/samples/effect-order-3/main.svelte
This file contains 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,18 @@ | ||
<script> | ||
let count = $state(0); | ||
function increment() { | ||
count += 1; | ||
console.log("in-increment", count); | ||
} | ||
$effect(() => { | ||
console.log("effect", count); | ||
}); | ||
$inspect(count); | ||
</script> | ||
|
||
<button onclick={increment}> | ||
clicks: {count} | ||
</button> |