diff --git a/src/generators/dom/visitors/IfBlock.ts b/src/generators/dom/visitors/IfBlock.ts index 7e294bc89f08..e36c5d998432 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 bf5690896d62..3177df9b0220 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 a4a22ba10501..ac25a686c6f2 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 000000000000..0789b1444589 --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/Level1.html @@ -0,0 +1,22 @@ +<div class="level1"> + {{#each values as value}} + <h4>level 1 #{{value}}</h4> + <Level2 condition="{{value % 2}}"> + <Level3> + <span>And more stuff goes in here</span> + </Level3> + </Level2> + {{/each}} +</div> + +<script> + import Level2 from './Level2.html'; + import Level3 from './Level3.html'; + + export default { + components: { + Level2, + Level3 + } + }; +</script> \ No newline at end of file diff --git a/test/runtime/samples/component-nested-deeper/Level2.html b/test/runtime/samples/component-nested-deeper/Level2.html new file mode 100644 index 000000000000..6742c7d7f90c --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/Level2.html @@ -0,0 +1,8 @@ +<div class="level2" ref:wat> + <h4>level 2</h4> + {{#if condition}} + <span>TRUE! {{yield}}</span> + {{else}} + <span>FALSE! {{yield}}</span> + {{/if}} +</div> \ No newline at end of file diff --git a/test/runtime/samples/component-nested-deeper/Level3.html b/test/runtime/samples/component-nested-deeper/Level3.html new file mode 100644 index 000000000000..e09fc525a8e1 --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/Level3.html @@ -0,0 +1,4 @@ +<div class="level3" ref:thingy> + <h4>level 3</h4> + {{yield}} +</div> \ No newline at end of file diff --git a/test/runtime/samples/component-nested-deeper/_config.js b/test/runtime/samples/component-nested-deeper/_config.js new file mode 100644 index 000000000000..8c525fedd475 --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/_config.js @@ -0,0 +1,9 @@ +export default { + data: { + values: [1, 2, 3, 4] + }, + + test(assert, component) { + component.set({ values: [2, 3] }); + } +}; diff --git a/test/runtime/samples/component-nested-deeper/main.html b/test/runtime/samples/component-nested-deeper/main.html new file mode 100644 index 000000000000..5ad2d9d319b9 --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/main.html @@ -0,0 +1,11 @@ +<Level1 :values/> + +<script> + import Level1 from './Level1.html'; + + export default { + components: { + Level1 + } + } +</script> \ No newline at end of file