Skip to content

Commit

Permalink
dont use skipped text nodes as anchors - fixes #843
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Sep 12, 2017
1 parent b64d950 commit 6147604
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/generators/dom/preprocess.ts
Expand Up @@ -417,6 +417,8 @@ function preprocessChildren(
const preprocessor = preprocessors[child.type];
if (preprocessor) preprocessor(generator, block, state, child, inEachBlock, elementStack, componentStack, stripWhitespace, cleaned[i + 1] || nextSibling);

if (child.shouldSkip) return;

if (lastChild) lastChild.next = child;
child.prev = lastChild;

Expand Down
25 changes: 25 additions & 0 deletions test/runtime/samples/svg-each-block-anchor/_config.js
@@ -0,0 +1,25 @@
export default {
data: {
foo: ['a'],
bar: ['c']
},

html: `
<svg>
<g class='foo'>a</g>
<g class='bar'>c</g>
</svg>
`,

test(assert, component, target) {
component.set({ foo: ['a', 'b'] });

assert.htmlEqual(target.innerHTML, `
<svg>
<g class='foo'>a</g>
<g class='foo'>b</g>
<g class='bar'>c</g>
</svg>
`);
}
};
9 changes: 9 additions & 0 deletions test/runtime/samples/svg-each-block-anchor/main.html
@@ -0,0 +1,9 @@
<svg>
{{#each foo as x}}
<g class='foo'></g>
{{/each}}

{{#each bar as y}}
<g class='bar'></g>
{{/each}}
</svg>

0 comments on commit 6147604

Please sign in to comment.