fix: treat snippets like normal components when inferring namespace

pull/10631/head
navorite 3 years ago
parent 83b92372c2
commit 3c64f5630a

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: treat snippets like normal components when inferring namespace

@ -245,11 +245,7 @@ function check_nodes_for_namespace(nodes, namespace) {
} else if (namespace === 'keep') {
namespace = 'svg';
}
} else if (
(node.type === 'Text' && node.data.trim() !== '') ||
node.type === 'HtmlTag' ||
node.type === 'RenderTag'
) {
} else if ((node.type === 'Text' && node.data.trim() !== '') || node.type === 'HtmlTag') {
namespace = 'maybe_html';
} else if (node.type === 'EachBlock') {
namespace = check_nodes_for_namespace(node.body.nodes, namespace);

@ -2,12 +2,16 @@
{#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}
{#each Array(2).fill(0) as item, idx}
<text x={idx * 10} y={42}>{idx}</text>
{/each}
<!-- comment should not set infer html namespace -->
{@render test("test")}
{#snippet test(text)}
<text x={20} y={42}>{text}</text>
{/snippet}
<!-- comment should not infer html namespace -->

@ -7,7 +7,7 @@ export default test({
<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>
<text x="20" y="42">test</text>
</svg>
`,
test({ assert, target }) {

Loading…
Cancel
Save