mirror of https://github.com/sveltejs/svelte
fix: ensure correct parent effect is associated with render effects (#13274)
* fix: ensure correct parent effect is associated with render effects * fix --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>better-docs-for-css-injected
parent
eba64f7cb3
commit
b624380c45
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: ensure correct parent effect is associated with render effects
|
@ -0,0 +1,19 @@
|
|||||||
|
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, [
|
||||||
|
{ count: 0, doubled: 0 },
|
||||||
|
{ count: 1, doubled: 2 },
|
||||||
|
{ count: 2, doubled: 4 }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,18 @@
|
|||||||
|
<script>
|
||||||
|
let count = $state(0);
|
||||||
|
|
||||||
|
function increment() {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$effect.pre(() => {
|
||||||
|
const doubled = count * 2;
|
||||||
|
$effect(() => {
|
||||||
|
console.log({ count, doubled });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={increment}>
|
||||||
|
clicks: {count}
|
||||||
|
</button>
|
Loading…
Reference in new issue