Skip to content

Incorrect validation for void svelte:element content presence #7566

Closed
@anatolipr

Description

@anatolipr

Describe the bug

with the fix for #7449 in 3.48.0 there was a new validation included which doesn't work correctly. The validation prevents content inside a void svelte:element and produces <svelte:element this="input"> is self-closing and cannot have content. if there is any content in the tag, including conditional ones, making it impossible to create universal code which dynamically contain content. For example this code is now considered invalid:

<svelte:element this={tag.type}>
    {#if tag.type !== 'input'}{tag.content}{/if}
</svelte:element>

although the above if statement will correctly not produce content.

Reproduction

See https://svelte.dev/repl/931558d3b0564db79064da1fedf0aa38?version=3.48.0 with a reproduced error.

Expected behavior - validation should either be optional or evaluate conditional content.

Current behavior - the fact that the content is not present is still considered as present.

Logs

No response

System Info

Any system, browser

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