-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: store access on component destroy
Co-authored-by: Oscar Dominguez <[email protected]>
- Loading branch information
1 parent
dc8ae82
commit 696b50f
Showing
6 changed files
with
96 additions
and
16 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: store access on component destroy |
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
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
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/store-update-on-destroy/Test.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,12 @@ | ||
<script lang="ts"> | ||
const { store } = $props(); | ||
$effect(() => { | ||
$store; | ||
return () => { | ||
console.log($store); | ||
$store++; | ||
console.log($store); | ||
}; | ||
}); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/store-update-on-destroy/_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,12 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
async test({ assert, target, logs }) { | ||
const input = target.querySelector('input'); | ||
flushSync(() => { | ||
input?.click(); | ||
}); | ||
assert.deepEqual(logs, [0, 1]); | ||
} | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/svelte/tests/runtime-runes/samples/store-update-on-destroy/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,15 @@ | ||
<script lang="ts"> | ||
import { writable } from 'svelte/store'; | ||
import Test from './Test.svelte'; | ||
let store = writable(0); | ||
let checked = $state(true); | ||
</script> | ||
|
||
<input type="checkbox" bind:checked /> | ||
|
||
{#if checked} | ||
<Test {store} /> | ||
{/if} |