forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure all effect cleanup functions are untracked (sveltejs#11567)
* fix: ensure all effect cleanup functions are untracked * add test --------- Co-authored-by: Rich Harris <[email protected]>
- Loading branch information
1 parent
f6e8777
commit 5497b3d
Showing
5 changed files
with
38 additions
and
0 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: ensure all effect cleanup functions are untracked |
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
4 changes: 4 additions & 0 deletions
4
packages/svelte/tests/runtime-runes/samples/effect-untrack-teardown/_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,4 @@ | ||
import { test } from '../../test'; | ||
|
||
// nothing to test here — if the teardown function is not untracked, effect will loop | ||
export default test({}); |
19 changes: 19 additions & 0 deletions
19
packages/svelte/tests/runtime-runes/samples/effect-untrack-teardown/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,19 @@ | ||
<script> | ||
let prop = $state(); | ||
let key = $state({}); | ||
function action() { | ||
prop = {}; | ||
$effect.pre(() => { | ||
return () => { | ||
prop; | ||
} | ||
}); | ||
} | ||
$effect(() => key = {}); | ||
</script> | ||
|
||
{#key key} | ||
<div use:action>test</div> | ||
{/key} |