mirror of https://github.com/sveltejs/svelte
commit
8431aff34f
@ -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>
|
@ -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>
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
import { onDestroy } from 'svelte';
|
||||
import { destroyed } from './destroyed.js';
|
||||
|
||||
let yes = 1;
|
||||
|
||||
onDestroy(() => destroyed.push('C'));
|
||||
</script>
|
@ -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();
|
||||
}
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
export const destroyed = [];
|
||||
|
||||
export const reset = () => destroyed.length = 0;
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
import A from './A.svelte';
|
||||
|
||||
export let visible = true;
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<A/>
|
||||
{/if}
|
Loading…
Reference in new issue