diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 753d1c8a9872..9221a683b851 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -54,7 +54,7 @@ export function destroy_component(component, detaching) { if (component.$$.fragment) { run_all(component.$$.on_destroy); - if (detaching) component.$$.fragment.d(1); + component.$$.fragment.d(detaching); // TODO null out other refs, including component.$$ (but need to // preserve final state?) diff --git a/test/runtime/samples/ondestroy-deep/A.svelte b/test/runtime/samples/ondestroy-deep/A.svelte new file mode 100644 index 000000000000..a1a740bc2ec2 --- /dev/null +++ b/test/runtime/samples/ondestroy-deep/A.svelte @@ -0,0 +1,15 @@ + + +
+ {#if yes} + + {/if} +
\ No newline at end of file diff --git a/test/runtime/samples/ondestroy-deep/B.svelte b/test/runtime/samples/ondestroy-deep/B.svelte new file mode 100644 index 000000000000..78b042f2d678 --- /dev/null +++ b/test/runtime/samples/ondestroy-deep/B.svelte @@ -0,0 +1,15 @@ + + +
+ {#if yes} + + {/if} +
\ No newline at end of file diff --git a/test/runtime/samples/ondestroy-deep/C.svelte b/test/runtime/samples/ondestroy-deep/C.svelte new file mode 100644 index 000000000000..27f33c93fcca --- /dev/null +++ b/test/runtime/samples/ondestroy-deep/C.svelte @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/test/runtime/samples/ondestroy-deep/_config.js b/test/runtime/samples/ondestroy-deep/_config.js new file mode 100644 index 000000000000..4431a2e16317 --- /dev/null +++ b/test/runtime/samples/ondestroy-deep/_config.js @@ -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(); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/ondestroy-deep/destroyed.js b/test/runtime/samples/ondestroy-deep/destroyed.js new file mode 100644 index 000000000000..fe05c1d241b3 --- /dev/null +++ b/test/runtime/samples/ondestroy-deep/destroyed.js @@ -0,0 +1,3 @@ +export const destroyed = []; + +export const reset = () => destroyed.length = 0; \ No newline at end of file diff --git a/test/runtime/samples/ondestroy-deep/main.svelte b/test/runtime/samples/ondestroy-deep/main.svelte new file mode 100644 index 000000000000..d584dc1b8553 --- /dev/null +++ b/test/runtime/samples/ondestroy-deep/main.svelte @@ -0,0 +1,9 @@ + + +{#if visible} + +{/if} \ No newline at end of file