mirror of https://github.com/sveltejs/svelte
fix: reset effects inside skipped branches (#17581)
* fix: prevent reactivity loss during fork fixes #17197, fixes #17304, fixes #17301, fixes #17309 * add samples * add changeset * fix var casing in tests * don't remove reactions during fork * add sample for derived dep tracking in fork * fix sample type check error * set derived.v on first eval in fork * add sample for derived.v remaining UNINITIALIZED * lost current_batch import in runtime.js * Delete how * Update packages/svelte/src/internal/client/reactivity/deriveds.js * delete test in favour of #17577 * extract runtime.js changes into separate PR * alternative approach * revert * clear skipped branches when deferring * fix * fix * changeset * rename test * update test * unused test --------- Co-authored-by: David Roizenman <david@hmnd.io> Co-authored-by: Paolo Ricciuti <ricciutipaolo@gmail.com> Co-authored-by: Tee Ming <chewteeming01@gmail.com>pull/17564/head
parent
3608b3c869
commit
1c131f11ca
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: reset effects inside skipped branches
|
||||
@ -0,0 +1,21 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
skip_no_async: true,
|
||||
async test({ assert, target }) {
|
||||
const [fork_btn, counter_btn] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => {
|
||||
fork_btn.click();
|
||||
});
|
||||
|
||||
assert.equal(counter_btn.textContent, '0');
|
||||
|
||||
flushSync(() => {
|
||||
counter_btn.click();
|
||||
});
|
||||
|
||||
assert.equal(counter_btn.textContent, '1');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,22 @@
|
||||
<script>
|
||||
let show = $state(false);
|
||||
let show_async = $state(false);
|
||||
let count = $state(0);
|
||||
</script>
|
||||
|
||||
<button onclick={() => {
|
||||
show = true;
|
||||
show_async = true;
|
||||
}}>show</button>
|
||||
|
||||
{#if show}
|
||||
hi
|
||||
{:else}
|
||||
{#if show || !show}
|
||||
<button onclick={() => count++}>{count}</button>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if show_async}
|
||||
{await new Promise(() => {})}
|
||||
{/if}
|
||||
Loading…
Reference in new issue