diff --git a/packages/svelte/src/internal/client/render.js b/packages/svelte/src/internal/client/render.js index 40307fb980..c65d697a1b 100644 --- a/packages/svelte/src/internal/client/render.js +++ b/packages/svelte/src/internal/client/render.js @@ -69,11 +69,13 @@ export function set_text(dom, value) { * @param {null | ((anchor: Comment) => void)} fallback_fn */ export function slot(anchor, $$props, slot_name, slot_props, fallback_fn) { + var is_snippet = false; var slot_fn = $$props.$$slots?.[slot_name]; if (slot_fn === true) { if (slot_name === 'default') { slot_fn = $$props.children; } else { + is_snippet = true; slot_fn = $$props[slot_name]; } } @@ -83,7 +85,7 @@ export function slot(anchor, $$props, slot_name, slot_props, fallback_fn) { fallback_fn(anchor); } } else { - slot_fn(anchor, slot_props); + slot_fn(anchor, is_snippet ? () => slot_props : slot_props); } } diff --git a/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/Child.svelte b/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/Child.svelte index c14bed8d55..49ef446e25 100644 --- a/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/Child.svelte +++ b/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/Child.svelte @@ -1,2 +1,2 @@

-

+

diff --git a/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/_config.js b/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/_config.js index 99e1719bf3..718ca9b50b 100644 --- a/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/_config.js +++ b/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/_config.js @@ -1,5 +1,5 @@ import { test } from '../../test'; export default test({ - html: `

Default

Named

` + html: `

Default

Named foo

` }); diff --git a/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/main.svelte b/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/main.svelte index d439d5bd69..01b827fa83 100644 --- a/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/main.svelte +++ b/packages/svelte/tests/runtime-runes/samples/snippet-slot-interop/main.svelte @@ -4,7 +4,7 @@ Default - {#snippet named()} - Named + {#snippet named({ foo })} + Named {foo} {/snippet}