Skip to content

Commit

Permalink
fix order of html tags when if in key block
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau committed Nov 17, 2020
1 parent 148b610 commit 309d691
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/compile/render_dom/wrappers/KeyBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class KeyBlockWrapper extends Wrapper {
renderer,
this.block,
node.children,
parent,
this,
strip_whitespace,
next_sibling
);
Expand Down
22 changes: 22 additions & 0 deletions test/runtime/samples/key-block-static-if/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
html: `
<section>
<div>Second</div>
</section>
<button>Click</button>
`,
async test({ assert, component, target, window }) {
const section = target.querySelector('section');
const button = target.querySelector('button');

await button.dispatchEvent(new window.Event('click'));

assert.htmlEqual(target.innerHTML, `
<section>
<div>First</div>
<div>Second</div>
</section>
<button>Click</button>
`);
}
};
17 changes: 17 additions & 0 deletions test/runtime/samples/key-block-static-if/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script>
let slide = 0;
let num = false;
const changeNum = () => num = !num;
</script>

<section>
{#key slide}
{#if num}
<div>First</div>
{/if}
{/key}
<div>Second</div>
</section>

<button on:click={changeNum}>Click</button>

0 comments on commit 309d691

Please sign in to comment.