comment fix + test case

pull/10027/head
navorite 3 years ago
parent 5598c4c48b
commit 117536288e

@ -222,7 +222,7 @@ export function infer_namespace(namespace, parent, nodes, path) {
only_svg = false;
break;
}
} else if (node.type !== 'Text' || node.data.trim() !== '') {
} else if (node.type !== 'Comment' && (node.type !== 'Text' || node.data.trim() !== '')) {
only_svg = false;
}
}

@ -0,0 +1,13 @@
<text x="0" y=14>outside</text>
{#if true}
<text x="0" y="26">true</text>
{:else}
<text x="0" y="26">false</text>
{/if}
{#each Array(3).fill(0) as item, idx}
<text x={idx * 10} y={42}>{idx}</text>
{/each}
<!-- comment should not set infer html namespace -->

@ -0,0 +1,26 @@
import { test, ok } from '../../test';
export default test({
html: `
<svg>
<text x="0" y="14">outside</text>
<text x="0" y="26">true</text>
<text x="0" y="42">0</text>
<text x="10" y="42">1</text>
<text x="20" y="42">2</text>
</svg>
`,
test({ assert, target }) {
const svg = target.querySelector('svg');
ok(svg);
assert.equal(svg.namespaceURI, 'http://www.w3.org/2000/svg');
const text_elements = target.querySelectorAll('text');
assert.equal(text_elements.length, 5);
for (const { namespaceURI } of text_elements)
assert.equal(namespaceURI, 'http://www.w3.org/2000/svg');
}
});

@ -0,0 +1,7 @@
<script>
import Wrapper from "./Wrapper.svelte";
</script>
<svg>
<Wrapper />
</svg>
Loading…
Cancel
Save