diff --git a/.changeset/shaggy-kids-juggle.md b/.changeset/shaggy-kids-juggle.md deleted file mode 100644 index ceb208dc4f40..000000000000 --- a/.changeset/shaggy-kids-juggle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/svelte': patch ---- - -Adds support for Svelte 5's new `@render` syntax while maintaining backward compatibility with traditional slots. diff --git a/packages/integrations/svelte/client-v5.js b/packages/integrations/svelte/client-v5.js index f2cc647a2be6..7a046b5bfd08 100644 --- a/packages/integrations/svelte/client-v5.js +++ b/packages/integrations/svelte/client-v5.js @@ -8,11 +8,7 @@ export default (element) => { let children = undefined; let $$slots = undefined; - let renderFns = {}; - - for (const [key, value] of Object.entries(slotted)) { - // Legacy slot support $$slots ??= {}; if (key === 'default') { $$slots.default = true; @@ -24,16 +20,6 @@ export default (element) => { render: () => `${value}`, })); } - // @render support for Svelte ^5.0 - if (key === 'default') { - renderFns.children = createRawSnippet(() => ({ - render: () => `${value}` - })); - } else { - renderFns[key] = createRawSnippet(() => ({ - render: () => `${value}` - })); - } } const bootstrap = client !== 'only' ? hydrate : mount; @@ -42,7 +28,6 @@ export default (element) => { ...props, children, $$slots, - ...renderFns }); } else { const component = bootstrap(Component, { @@ -51,7 +36,6 @@ export default (element) => { ...props, children, $$slots, - ...renderFns }, }); existingApplications.set(element, component); diff --git a/packages/integrations/svelte/server-v5.js b/packages/integrations/svelte/server-v5.js index 932a52b1ff06..acffd10dfef0 100644 --- a/packages/integrations/svelte/server-v5.js +++ b/packages/integrations/svelte/server-v5.js @@ -17,10 +17,7 @@ async function renderToStaticMarkup(Component, props, slotted, metadata) { let children = undefined; let $$slots = undefined; - const renderProps = {}; - for (const [key, value] of Object.entries(slotted)) { - // Legacy slot support $$slots ??= {}; if (key === 'default') { $$slots.default = true; @@ -32,11 +29,6 @@ async function renderToStaticMarkup(Component, props, slotted, metadata) { render: () => `<${tagName} name="${key}">${value}`, })); } - // @render support for Svelte ^5.0 - const slotName = key === 'default' ? 'children' : key; - renderProps[slotName] = createRawSnippet(() => ({ - render: () => `<${tagName}${key !== 'default' ? ` name="${key}"` : ''}>${value}` - })); } const result = render(Component, { @@ -44,7 +36,6 @@ async function renderToStaticMarkup(Component, props, slotted, metadata) { ...props, children, $$slots, - ...renderProps }, }); return { html: result.body };