mirror of https://github.com/sveltejs/svelte
fix: infer `svg` namespace correctly (#10027)
Add recursive check for logic blocks, ignore things such as ConstTags and Comments closes #10025 --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/10128/head
parent
f5dc562ee7
commit
cd2263fdab
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: infer `svg` namespace correctly
|
@ -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…
Reference in new issue