From 002ffa208d79f684480411f9570bd17145af550c Mon Sep 17 00:00:00 2001 From: Tan Li Hau Date: Tue, 17 Nov 2020 22:26:26 +0800 Subject: [PATCH] fix order of html tags when if in key block --- .../compile/render_dom/wrappers/KeyBlock.ts | 2 +- .../samples/key-block-static-if/_config.js | 21 +++++++++++++++++++ .../samples/key-block-static-if/main.svelte | 17 +++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/key-block-static-if/_config.js create mode 100644 test/runtime/samples/key-block-static-if/main.svelte diff --git a/src/compiler/compile/render_dom/wrappers/KeyBlock.ts b/src/compiler/compile/render_dom/wrappers/KeyBlock.ts index 9688337d7c..cbd021ff6c 100644 --- a/src/compiler/compile/render_dom/wrappers/KeyBlock.ts +++ b/src/compiler/compile/render_dom/wrappers/KeyBlock.ts @@ -44,7 +44,7 @@ export default class KeyBlockWrapper extends Wrapper { renderer, this.block, node.children, - parent, + this, strip_whitespace, next_sibling ); diff --git a/test/runtime/samples/key-block-static-if/_config.js b/test/runtime/samples/key-block-static-if/_config.js new file mode 100644 index 0000000000..2926ad7c24 --- /dev/null +++ b/test/runtime/samples/key-block-static-if/_config.js @@ -0,0 +1,21 @@ +export default { + html: ` +
+
Second
+
+ + `, + async test({ assert, component, target, window }) { + const button = target.querySelector('button'); + + await button.dispatchEvent(new window.Event('click')); + + assert.htmlEqual(target.innerHTML, ` +
+
First
+
Second
+
+ + `); + } +}; diff --git a/test/runtime/samples/key-block-static-if/main.svelte b/test/runtime/samples/key-block-static-if/main.svelte new file mode 100644 index 0000000000..cbacb77674 --- /dev/null +++ b/test/runtime/samples/key-block-static-if/main.svelte @@ -0,0 +1,17 @@ + + +
+ {#key slide} + {#if num} +
First
+ {/if} + {/key} +
Second
+
+ + \ No newline at end of file