mirror of https://github.com/sveltejs/svelte
This reverts commit 95e5175581
.
pull/16603/head
parent
2b85d2a544
commit
f5d4350f3d
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'svelte': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
fix: destroy dynamic component instance before creating new one
|
|
@ -1,8 +0,0 @@
|
|||||||
<script>
|
|
||||||
$effect.pre(() => {
|
|
||||||
console.log('create A');
|
|
||||||
return () => console.log('destroy A');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h1>A</h1>
|
|
@ -1,8 +0,0 @@
|
|||||||
<script>
|
|
||||||
$effect.pre(() => {
|
|
||||||
console.log('create B');
|
|
||||||
return () => console.log('destroy B');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h1>B</h1>
|
|
@ -1,13 +0,0 @@
|
|||||||
import { test } from '../../test';
|
|
||||||
import { flushSync } from 'svelte';
|
|
||||||
|
|
||||||
export default test({
|
|
||||||
mode: ['client', 'hydrate'],
|
|
||||||
|
|
||||||
async test({ assert, target, logs }) {
|
|
||||||
const [button] = target.querySelectorAll('button');
|
|
||||||
|
|
||||||
flushSync(() => button.click());
|
|
||||||
assert.deepEqual(logs, ['create A', 'destroy A', 'create B']);
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,13 +0,0 @@
|
|||||||
<script>
|
|
||||||
import A from './A.svelte';
|
|
||||||
import B from './B.svelte';
|
|
||||||
|
|
||||||
let condition = $state(true);
|
|
||||||
let Component = $derived(condition ? A : B);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<button onclick={() => condition = !condition}>
|
|
||||||
toggle ({condition})
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<Component />
|
|
Loading…
Reference in new issue