fix: ensure clearing of old values happens independent of root flushes (#15664)

* fix: ensure clearing of old values happens indepedent of root flushes

* lint

* test
pull/15665/head
Dominic Gannaway 5 months ago committed by GitHub
parent 5b9053d111
commit 80557bbc1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure clearing of old values happens independent of root flushes

@ -692,6 +692,7 @@ function flush_queued_root_effects() {
var collected_effects = process_effects(root_effects[i]);
flush_queued_effects(collected_effects);
}
old_values.clear();
}
} finally {
is_flushing = false;
@ -701,7 +702,6 @@ function flush_queued_root_effects() {
if (DEV) {
dev_effect_stack = [];
}
old_values.clear();
}
}

@ -0,0 +1,12 @@
<script>
import { onMount } from 'svelte'
let thing = $state(0)
onMount(() => {
thing = 1;
return () => {
console.log(thing);
}
})
</script>

@ -0,0 +1,7 @@
import { test } from '../../test';
export default test({
async test({ assert, logs }) {
assert.deepEqual(logs, [1]);
}
});

@ -0,0 +1,14 @@
<script>
import { onMount } from "svelte"
import Component from './Component.svelte';
let key = $state(0);
onMount(() => {
key = 1;
})
</script>
{#key key}
<Component />
{/key}
Loading…
Cancel
Save