-
-
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.
always run onDestroy functions - fixes #3058
- Loading branch information
1 parent
e09014b
commit 0e90ddc
Showing
7 changed files
with
61 additions
and
1 deletion.
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
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> | ||
import { onDestroy } from 'svelte'; | ||
import { destroyed } from './destroyed.js'; | ||
import B from './B.svelte'; | ||
let yes = 1; | ||
onDestroy(() => destroyed.push('A')); | ||
</script> | ||
|
||
<div> | ||
{#if yes} | ||
<B/> | ||
{/if} | ||
</div> |
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> | ||
import { onDestroy } from 'svelte'; | ||
import { destroyed } from './destroyed.js'; | ||
import C from './C.svelte'; | ||
let yes = 1; | ||
onDestroy(() => destroyed.push('B')); | ||
</script> | ||
|
||
<div> | ||
{#if yes} | ||
<C/> | ||
{/if} | ||
</div> |
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,8 @@ | ||
<script> | ||
import { onDestroy } from 'svelte'; | ||
import { destroyed } from './destroyed.js'; | ||
let yes = 1; | ||
onDestroy(() => destroyed.push('C')); | ||
</script> |
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,10 @@ | ||
import { destroyed, reset } from './destroyed.js'; | ||
|
||
export default { | ||
test({ assert, component }) { | ||
component.visible = false; | ||
assert.deepEqual(destroyed, ['A', 'B', 'C']); | ||
|
||
reset(); | ||
} | ||
}; |
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,3 @@ | ||
export let destroyed = []; | ||
|
||
export const reset = () => destroyed.length = 0; |
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,9 @@ | ||
<script> | ||
import A from './A.svelte'; | ||
export let visible = true; | ||
</script> | ||
|
||
{#if visible} | ||
<A/> | ||
{/if} |