Skip to content

Svelte 5: <svelte:self /> can't be directly added to a {#snippet} #9436

@robertadamsonsmith

Description

@robertadamsonsmith

Describe the bug

Adding <svelte:self /> directly to a {#snippet}, raises the error:

<svelte:self> components can only exist inside {#if} blocks, {#each} blocks, or slots passed to components

I would have expected it to be allowed though. Adding an {#if true} block to the snippet effectively silences the error, allowing the expected behaviour.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACn2SMW-DMBCF_8qVdEikIJKONEXt2L2dSgdiH40Vc7Z8pmmE-O89Q6SkSxfEw_fefQ8YstZY5Kz8GDJqOszK7MX7bJ3Fs0-Cv9FGFM2uDyo92bEKxseqpjpajDAo11OEJ9huRrne--A8L1ePNe2K6yjNY2O63d3lOdT0Tsp1HVI09AXxgNA6a90pKeU0rkGSdK-Q5dAwYAgulOKekUpG21Yy2XlHEsKgGgJH9gz4YziCITYaYViYdoS9derIa1HYqMNVuwBsnZh9w4waortJrCnPqxlX-BdMxnsp_IYcH5ZTnVXqE2-JLq9jhEKcQ3HxjJeoS_fXOMHuEbpGEGXpyYVj0o3Wqb8cztyn0Ig_wOT-i3BLkIYhhh4n9Q-RjBaS-xctJYt__o4VbObI54CkZfV1V75dTc4pQH6JzmnTGtRZOa3-HH8BvP-Y000CAAA=

Logs

No response

System Info

https://svelte-5-preview.vercel.app/

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