From dc0dedf3fe7ce813990cc6ac086116a075791354 Mon Sep 17 00:00:00 2001 From: Paul Sauve Date: Thu, 15 Jun 2017 22:28:50 -0500 Subject: [PATCH 1/4] Fix #643 --- src/generators/dom/visitors/IfBlock.ts | 7 ++++++- test/js/samples/if-block-no-update/expected-bundle.js | 4 +++- test/js/samples/if-block-no-update/expected.js | 6 ++++-- 3 files changed, 13 insertions(+), 4 deletions(-) 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; From e9516abffd4d5526c314ea9881c047b4bd969342 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 16 Jun 2017 10:47:19 -0400 Subject: [PATCH 2/4] fix bad indentation in generated code --- src/generators/dom/visitors/IfBlock.ts | 8 ++------ test/js/samples/if-block-no-update/expected-bundle.js | 8 ++------ test/js/samples/if-block-no-update/expected.js | 8 ++------ 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/generators/dom/visitors/IfBlock.ts b/src/generators/dom/visitors/IfBlock.ts index 16f0ce795b..e36c5d9984 100644 --- a/src/generators/dom/visitors/IfBlock.ts +++ b/src/generators/dom/visitors/IfBlock.ts @@ -272,15 +272,11 @@ function compound( } block.builders.unmount.addLine( - `${if_name}{ - ${name}.unmount(); - }` + `${if_name}${name}.unmount();` ); block.builders.destroy.addLine( - `${if_name}{ - ${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 b1c908a8da..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,16 +164,12 @@ function create_main_fragment ( state, component ) { }, unmount: function () { - { - if_block.unmount(); - } + if_block.unmount(); detachNode( if_block_anchor ); }, destroy: function () { - { - 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 63f272f1d1..ac25a686c6 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -29,16 +29,12 @@ function create_main_fragment ( state, component ) { }, unmount: function () { - { - if_block.unmount(); - } + if_block.unmount(); detachNode( if_block_anchor ); }, destroy: function () { - { - if_block.destroy(); - } + if_block.destroy(); } }; } From 78b3a1b0791c801e8a1cb2bdb0e8fc9b5781d66a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 17 Jun 2017 11:22:49 -0400 Subject: [PATCH 3/4] add test for #643 --- .../component-nested-deeper/Level1.html | 22 +++++++++++++++++++ .../component-nested-deeper/Level2.html | 8 +++++++ .../component-nested-deeper/Level3.html | 4 ++++ .../component-nested-deeper/_config.js | 11 ++++++++++ .../samples/component-nested-deeper/main.html | 11 ++++++++++ 5 files changed, 56 insertions(+) create mode 100644 test/runtime/samples/component-nested-deeper/Level1.html create mode 100644 test/runtime/samples/component-nested-deeper/Level2.html create mode 100644 test/runtime/samples/component-nested-deeper/Level3.html create mode 100644 test/runtime/samples/component-nested-deeper/_config.js create mode 100644 test/runtime/samples/component-nested-deeper/main.html 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 @@ +
+ {{#each values as value}} +

level 1 #{{value}}

+ + + And more stuff goes in here + + + {{/each}} +
+ + \ 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 0000000000..6742c7d7f9 --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/Level2.html @@ -0,0 +1,8 @@ +
+

level 2

+ {{#if condition}} + TRUE! {{yield}} + {{else}} + FALSE! {{yield}} + {{/if}} +
\ 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 0000000000..e09fc525a8 --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/Level3.html @@ -0,0 +1,4 @@ +
+

level 3

+ {{yield}} +
\ 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 0000000000..6b216f84d6 --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/_config.js @@ -0,0 +1,11 @@ +export default { + solo: true, + + 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 0000000000..5ad2d9d319 --- /dev/null +++ b/test/runtime/samples/component-nested-deeper/main.html @@ -0,0 +1,11 @@ + + + \ No newline at end of file From 3c36b77c1cd68a88606af8664c5ce6ff5718c5f3 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 17 Jun 2017 11:25:47 -0400 Subject: [PATCH 4/4] doh --- test/runtime/samples/component-nested-deeper/_config.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/runtime/samples/component-nested-deeper/_config.js b/test/runtime/samples/component-nested-deeper/_config.js index 6b216f84d6..8c525fedd4 100644 --- a/test/runtime/samples/component-nested-deeper/_config.js +++ b/test/runtime/samples/component-nested-deeper/_config.js @@ -1,6 +1,4 @@ export default { - solo: true, - data: { values: [1, 2, 3, 4] },