From 3e11b892447a466c95ed85d6a7fd14c54b9c5200 Mon Sep 17 00:00:00 2001 From: Matei Trandafir Date: Wed, 8 Jan 2025 22:54:41 +0200 Subject: [PATCH] docs: improve section for snippets-slots interop (#13869) * docs: improve section for snippets-slots interop * tweak --------- Co-authored-by: Rich Harris --- .../docs/07-misc/07-v5-migration-guide.md | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/documentation/docs/07-misc/07-v5-migration-guide.md b/documentation/docs/07-misc/07-v5-migration-guide.md index 29179cd849..ce95bf6ac7 100644 --- a/documentation/docs/07-misc/07-v5-migration-guide.md +++ b/documentation/docs/07-misc/07-v5-migration-guide.md @@ -339,7 +339,31 @@ When spreading props, local event handlers must go _after_ the spread, or they r In Svelte 4, content can be passed to components using slots. Svelte 5 replaces them with snippets which are more powerful and flexible, and as such slots are deprecated in Svelte 5. -They continue to work, however, and you can mix and match snippets and slots in your components. +They continue to work, however, and you can pass snippets to a component that uses slots: + +```svelte + + +
+ +``` + +```svelte + + + + + default child content + + {#snippet foo({ message })} + message from child: {message} + {/snippet} + +``` + +(The reverse is not true — you cannot pass slotted content to a component that uses [`{@render ...}`](/docs/svelte/@render) tags.) When using custom elements, you should still use `` like before. In a future version, when Svelte removes its internal version of slots, it will leave those slots as-is, i.e. output a regular DOM tag instead of transforming it.