Skip to content

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

@brunnerh

Description

@brunnerh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions