diff --git a/src/generators/dom/visitors/IfBlock.ts b/src/generators/dom/visitors/IfBlock.ts index 7e294bc89f..e36c5d9984 100644 --- a/src/generators/dom/visitors/IfBlock.ts +++ b/src/generators/dom/visitors/IfBlock.ts @@ -271,11 +271,12 @@ function compound( `); } + block.builders.unmount.addLine( + `${if_name}${name}.unmount();` + ); + block.builders.destroy.addLine( - `${if_name}{ - ${name}.unmount(); - ${name}.destroy(); - }` + `${if_name}${name}.destroy();` ); } diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js index bf5690896d..3177df9b02 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -164,14 +164,12 @@ function create_main_fragment ( state, component ) { }, unmount: function () { + if_block.unmount(); detachNode( if_block_anchor ); }, destroy: function () { - { - if_block.unmount(); - if_block.destroy(); - } + if_block.destroy(); } }; } diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index a4a22ba105..ac25a686c6 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -29,14 +29,12 @@ function create_main_fragment ( state, component ) { }, unmount: function () { + if_block.unmount(); detachNode( if_block_anchor ); }, destroy: function () { - { - if_block.unmount(); - if_block.destroy(); - } + if_block.destroy(); } }; } @@ -116,4 +114,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio this._torndown = true; }; -export default SvelteComponent; \ No newline at end of file +export default SvelteComponent; diff --git a/test/runtime/samples/component-nested-deeper/Level1.html b/test/runtime/samples/component-nested-deeper/Level1.html new file mode 100644 index 0000000000..0789b14445 --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/Level1.html @@ -0,0 +1,22 @@ +