diff --git a/src/generators/dom/visitors/IfBlock.ts b/src/generators/dom/visitors/IfBlock.ts index 7e294bc89f..16f0ce795b 100644 --- a/src/generators/dom/visitors/IfBlock.ts +++ b/src/generators/dom/visitors/IfBlock.ts @@ -271,9 +271,14 @@ function compound( `); } - block.builders.destroy.addLine( + block.builders.unmount.addLine( `${if_name}{ ${name}.unmount(); + }` + ); + + block.builders.destroy.addLine( + `${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..b1c908a8da 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -164,12 +164,14 @@ function create_main_fragment ( state, component ) { }, unmount: function () { + { + if_block.unmount(); + } detachNode( if_block_anchor ); }, destroy: function () { { - if_block.unmount(); 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..63f272f1d1 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -29,12 +29,14 @@ function create_main_fragment ( state, component ) { }, unmount: function () { + { + if_block.unmount(); + } detachNode( if_block_anchor ); }, destroy: function () { { - if_block.unmount(); if_block.destroy(); } } @@ -116,4 +118,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio this._torndown = true; }; -export default SvelteComponent; \ No newline at end of file +export default SvelteComponent;