Skip to content

Commit

Permalink
Merge pull request #844 from sveltejs/gh-843
Browse files Browse the repository at this point in the history
don't use skipped text nodes as anchors
  • Loading branch information
Rich-Harris authored Sep 12, 2017
2 parents b64d950 + 6147604 commit 129fb15
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 129fb15

Please sign in to comment.