From 079bd4e58ab56de17440254d07b7612398aece2a Mon Sep 17 00:00:00 2001 From: Yury Zhuravlev Date: Mon, 22 Oct 2018 14:33:16 +0900 Subject: [PATCH] fix #1780 just start use parent instead parent.parent in IfBlock wrapper --- src/compile/render-dom/wrappers/IfBlock.ts | 2 +- .../samples/each-block-in-if-block/_config.js | 13 +++++++++++++ .../samples/each-block-in-if-block/main.html | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/each-block-in-if-block/_config.js create mode 100644 test/runtime/samples/each-block-in-if-block/main.html diff --git a/src/compile/render-dom/wrappers/IfBlock.ts b/src/compile/render-dom/wrappers/IfBlock.ts index 284cd241de12..3505ec9ce082 100644 --- a/src/compile/render-dom/wrappers/IfBlock.ts +++ b/src/compile/render-dom/wrappers/IfBlock.ts @@ -41,7 +41,7 @@ class IfBlockBranch extends Wrapper { ) }); - this.fragment = new FragmentWrapper(renderer, this.block, node.children, parent.parent, stripWhitespace, nextSibling); + this.fragment = new FragmentWrapper(renderer, this.block, node.children, parent, stripWhitespace, nextSibling); this.isDynamic = this.block.dependencies.size > 0; } diff --git a/test/runtime/samples/each-block-in-if-block/_config.js b/test/runtime/samples/each-block-in-if-block/_config.js new file mode 100644 index 000000000000..2af8c4bcd360 --- /dev/null +++ b/test/runtime/samples/each-block-in-if-block/_config.js @@ -0,0 +1,13 @@ +export default { + data: { + dummy: false, + fruits: ['Apple', 'Banana', 'Tomato'], + }, + + html: '
Apple
Banana
Tomato
', + + test ( assert, component, target ) { + component.set({ dummy: true }); + assert.htmlEqual(target.innerHTML, '
Apple
Banana
Tomato
' ); + } +}; diff --git a/test/runtime/samples/each-block-in-if-block/main.html b/test/runtime/samples/each-block-in-if-block/main.html new file mode 100644 index 000000000000..4c71f3e5b353 --- /dev/null +++ b/test/runtime/samples/each-block-in-if-block/main.html @@ -0,0 +1,7 @@ +
+ {#if fruits} + {#each fruits as fruit (fruit)} +
{fruit}
+ {/each} + {/if} +
\ No newline at end of file