0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

[ci] format

This commit is contained in:
Bjorn Lu 2024-11-06 14:16:10 +00:00 committed by astrobot-houston
parent 6fd3d5960f
commit 4a35c505e4
2 changed files with 17 additions and 18 deletions

View file

@ -10,7 +10,6 @@ export default (element) => {
let $$slots = undefined; let $$slots = undefined;
let renderFns = {}; let renderFns = {};
for (const [key, value] of Object.entries(slotted)) { for (const [key, value] of Object.entries(slotted)) {
// Legacy slot support // Legacy slot support
$$slots ??= {}; $$slots ??= {};
@ -25,15 +24,15 @@ export default (element) => {
})); }));
} }
// @render support for Svelte ^5.0 // @render support for Svelte ^5.0
if (key === 'default') { if (key === 'default') {
renderFns.children = createRawSnippet(() => ({ renderFns.children = createRawSnippet(() => ({
render: () => `<astro-slot>${value}</astro-slot>` render: () => `<astro-slot>${value}</astro-slot>`,
})); }));
} else { } else {
renderFns[key] = createRawSnippet(() => ({ renderFns[key] = createRawSnippet(() => ({
render: () => `<astro-slot name="${key}">${value}</astro-slot>` render: () => `<astro-slot name="${key}">${value}</astro-slot>`,
})); }));
} }
} }
const bootstrap = client !== 'only' ? hydrate : mount; const bootstrap = client !== 'only' ? hydrate : mount;
@ -42,7 +41,7 @@ export default (element) => {
...props, ...props,
children, children,
$$slots, $$slots,
...renderFns ...renderFns,
}); });
} else { } else {
const component = bootstrap(Component, { const component = bootstrap(Component, {
@ -51,7 +50,7 @@ export default (element) => {
...props, ...props,
children, children,
$$slots, $$slots,
...renderFns ...renderFns,
}, },
}); });
existingApplications.set(element, component); existingApplications.set(element, component);

View file

@ -33,10 +33,10 @@ async function renderToStaticMarkup(Component, props, slotted, metadata) {
})); }));
} }
// @render support for Svelte ^5.0 // @render support for Svelte ^5.0
const slotName = key === 'default' ? 'children' : key; const slotName = key === 'default' ? 'children' : key;
renderProps[slotName] = createRawSnippet(() => ({ renderProps[slotName] = createRawSnippet(() => ({
render: () => `<${tagName}${key !== 'default' ? ` name="${key}"` : ''}>${value}</${tagName}>` render: () => `<${tagName}${key !== 'default' ? ` name="${key}"` : ''}>${value}</${tagName}>`,
})); }));
} }
const result = render(Component, { const result = render(Component, {
@ -44,7 +44,7 @@ async function renderToStaticMarkup(Component, props, slotted, metadata) {
...props, ...props,
children, children,
$$slots, $$slots,
...renderProps ...renderProps,
}, },
}); });
return { html: result.body }; return { html: result.body };