mirror of https://github.com/sveltejs/svelte
fix: cleanup non-branch effects created inside block effects (#13600)
* fix: cleanup non-branch effects created inside block effects * cleanerpull/13545/head
parent
eafddf4358
commit
4dcac41c10
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: cleanup non-branch effects created inside block effects
|
@ -0,0 +1,13 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target, instance, logs }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
assert.deepEqual(logs, ['effect', 1]);
|
||||||
|
flushSync(() => {
|
||||||
|
button?.click();
|
||||||
|
});
|
||||||
|
assert.deepEqual(logs, ['effect', 1, 'clean', 1, 'effect', 2]);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,18 @@
|
|||||||
|
<script>
|
||||||
|
let count = $state(1);
|
||||||
|
function track(value){
|
||||||
|
let val = value;
|
||||||
|
$effect(() => {
|
||||||
|
console.log("effect", val);
|
||||||
|
return ()=>{
|
||||||
|
console.log("clean", val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if track(count)}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<button onclick={()=> count++}></button>
|
Loading…
Reference in new issue