Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored and astrobot-houston committed Nov 6, 2024
1 parent 6fd3d59 commit 4a35c50
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
23 changes: 11 additions & 12 deletions packages/integrations/svelte/client-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default (element) => {
let $$slots = undefined;
let renderFns = {};


for (const [key, value] of Object.entries(slotted)) {
// Legacy slot support
$$slots ??= {};
Expand All @@ -25,15 +24,15 @@ export default (element) => {
}));
}
// @render support for Svelte ^5.0
if (key === 'default') {
renderFns.children = createRawSnippet(() => ({
render: () => `<astro-slot>${value}</astro-slot>`
}));
} else {
renderFns[key] = createRawSnippet(() => ({
render: () => `<astro-slot name="${key}">${value}</astro-slot>`
}));
}
if (key === 'default') {
renderFns.children = createRawSnippet(() => ({
render: () => `<astro-slot>${value}</astro-slot>`,
}));
} else {
renderFns[key] = createRawSnippet(() => ({
render: () => `<astro-slot name="${key}">${value}</astro-slot>`,
}));
}
}

const bootstrap = client !== 'only' ? hydrate : mount;
Expand All @@ -42,7 +41,7 @@ export default (element) => {
...props,
children,
$$slots,
...renderFns
...renderFns,
});
} else {
const component = bootstrap(Component, {
Expand All @@ -51,7 +50,7 @@ export default (element) => {
...props,
children,
$$slots,
...renderFns
...renderFns,
},
});
existingApplications.set(element, component);
Expand Down
12 changes: 6 additions & 6 deletions packages/integrations/svelte/server-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 ??= {};
Expand All @@ -33,18 +33,18 @@ async function renderToStaticMarkup(Component, props, slotted, metadata) {
}));
}
// @render support for Svelte ^5.0
const slotName = key === 'default' ? 'children' : key;
renderProps[slotName] = createRawSnippet(() => ({
render: () => `<${tagName}${key !== 'default' ? ` name="${key}"` : ''}>${value}</${tagName}>`
}));
const slotName = key === 'default' ? 'children' : key;
renderProps[slotName] = createRawSnippet(() => ({
render: () => `<${tagName}${key !== 'default' ? ` name="${key}"` : ''}>${value}</${tagName}>`,
}));
}

const result = render(Component, {
props: {
...props,
children,
$$slots,
...renderProps
...renderProps,
},
});
return { html: result.body };
Expand Down

0 comments on commit 4a35c50

Please sign in to comment.