Skip to content

Commit

Permalink
Merge branch 'fix-lost-anchor-if-if-block-first' of https://github.co…
Browse files Browse the repository at this point in the history
…m/stalkerg/svelte into stalkerg-fix-lost-anchor-if-if-block-first
  • Loading branch information
Rich-Harris committed Oct 20, 2018
2 parents 9e899db + 21ea87c commit e5f5995
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/compile/render-dom/wrappers/Fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ export default class FragmentWrapper {
this.nodes.unshift(wrapper);

link(lastChild, lastChild = wrapper);
}

else {
} else {
const Wrapper = wrappers[child.type];
if (!Wrapper) continue;

Expand All @@ -120,10 +118,6 @@ export default class FragmentWrapper {
if (!first.data) {
first.var = null;
this.nodes.shift();

if (this.nodes.length) {
link(null, this.nodes[0]);
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/runtime/samples/if-block-first/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
data: {
visible: false
},

html: '<div><div>before me</div></div>',

test ( assert, component, target ) {
component.set({ visible: true });
assert.htmlEqual(target.innerHTML, '<div><div>i am visible</div><div>before me</div></div>' );
}
};
6 changes: 6 additions & 0 deletions test/runtime/samples/if-block-first/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
{#if visible}
<div>i am visible</div>
{/if}
<div>before me</div>
</div>

0 comments on commit e5f5995

Please sign in to comment.