sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
76.8k stars 3.98k forks source link

Svelte 5: Snippet definitions cause error in certain elements #11462

Closed brunnerh closed 1 week ago

brunnerh commented 2 weeks ago

Describe the bug

Ran into an error when adding a snippet in a table row, as the compiler does not seem to realize that the snippet content is not directly inserted into the element hierarchy at the point of definition, resulting in a false positive.

Reproduction

<table>
    <tbody>
        <tr>
            {#snippet cell(v)}Value: {v}{/snippet}
            {#each [1, 2, 3] as v}
                <td>{@render cell(v)}</td>
            {/each}
        </tr>
    </tbody>
</table>

Text node is invalid inside <tr>

REPL

Logs

No response

System Info

REPL

Severity

annoyance