[ci] format
This commit is contained in:
parent
3d525efc95
commit
34202616c2
6 changed files with 32 additions and 20 deletions
|
@ -77,7 +77,7 @@ async function renderFrameworkComponent(
|
|||
const { renderers, clientDirectives } = result._metadata;
|
||||
const metadata: AstroComponentMetadata = {
|
||||
astroStaticSlot: true,
|
||||
displayName
|
||||
displayName,
|
||||
};
|
||||
|
||||
const { hydration, isPage, props } = extractDirectives(_props, clientDirectives);
|
||||
|
@ -273,7 +273,9 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
|
|||
if (isPage || renderer?.name === 'astro:jsx') {
|
||||
yield html;
|
||||
} else if (html && html.length > 0) {
|
||||
yield markHTMLString(removeStaticAstroSlot(html, renderer?.ssr?.supportsAstroStaticSlot ?? false));
|
||||
yield markHTMLString(
|
||||
removeStaticAstroSlot(html, renderer?.ssr?.supportsAstroStaticSlot ?? false)
|
||||
);
|
||||
} else {
|
||||
yield '';
|
||||
}
|
||||
|
@ -298,8 +300,10 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
|
|||
if (html) {
|
||||
if (Object.keys(children).length > 0) {
|
||||
for (const key of Object.keys(children)) {
|
||||
let tagName = renderer?.ssr?.supportsAstroStaticSlot ?
|
||||
!!metadata.hydrate ? 'astro-slot' : 'astro-static-slot'
|
||||
let tagName = renderer?.ssr?.supportsAstroStaticSlot
|
||||
? !!metadata.hydrate
|
||||
? 'astro-slot'
|
||||
: 'astro-static-slot'
|
||||
: 'astro-slot';
|
||||
let expectedHTML = key === 'default' ? `<${tagName}>` : `<${tagName} name="${key}">`;
|
||||
if (!html.includes(expectedHTML)) {
|
||||
|
|
|
@ -11,7 +11,7 @@ const slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w
|
|||
let originalConsoleError: typeof console.error;
|
||||
let consoleFilterRefs = 0;
|
||||
|
||||
function check(this: RendererContext, Component: any, props: Record<string, any>, children: any, ) {
|
||||
function check(this: RendererContext, Component: any, props: Record<string, any>, children: any) {
|
||||
if (typeof Component !== 'function') return false;
|
||||
|
||||
if (Component.prototype != null && typeof Component.prototype.render === 'function') {
|
||||
|
@ -49,7 +49,7 @@ function renderToStaticMarkup(
|
|||
Component: any,
|
||||
props: Record<string, any>,
|
||||
{ default: children, ...slotted }: Record<string, any>,
|
||||
metadata: AstroComponentMetadata | undefined,
|
||||
metadata: AstroComponentMetadata | undefined
|
||||
) {
|
||||
const ctx = getContext(this.result);
|
||||
|
||||
|
@ -59,7 +59,7 @@ function renderToStaticMarkup(
|
|||
slots[name] = h(StaticHtml, {
|
||||
hydrate: shouldHydrate(metadata),
|
||||
value,
|
||||
name
|
||||
name,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -72,9 +72,16 @@ function renderToStaticMarkup(
|
|||
serializeSignals(ctx, props, attrs, propsMap);
|
||||
|
||||
const html = render(
|
||||
h(Component, newProps, children != null ? h(StaticHtml, {
|
||||
hydrate: shouldHydrate(metadata),
|
||||
value: children}) : children)
|
||||
h(
|
||||
Component,
|
||||
newProps,
|
||||
children != null
|
||||
? h(StaticHtml, {
|
||||
hydrate: shouldHydrate(metadata),
|
||||
value: children,
|
||||
})
|
||||
: children
|
||||
)
|
||||
);
|
||||
return {
|
||||
attrs,
|
||||
|
|
|
@ -4,7 +4,7 @@ type Props = {
|
|||
value: string;
|
||||
name?: string;
|
||||
hydrate?: boolean;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Astro passes `children` as a string of HTML, so we need
|
||||
|
|
|
@ -68,7 +68,7 @@ function renderToStaticMarkup(Component, props, { default: children, ...slotted
|
|||
newProps.children = React.createElement(StaticHtml, {
|
||||
// Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot`
|
||||
hydrate: metadata.astroStaticSlot ? !!metadata.hydrate : true,
|
||||
value: newChildren
|
||||
value: newChildren,
|
||||
});
|
||||
}
|
||||
const vnode = React.createElement(Component, newProps);
|
||||
|
|
|
@ -77,7 +77,7 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl
|
|||
slots[name] = React.createElement(StaticHtml, {
|
||||
hydrate: needsHydration(metadata),
|
||||
value,
|
||||
name
|
||||
name,
|
||||
});
|
||||
}
|
||||
// Note: create newProps to avoid mutating `props` before they are serialized
|
||||
|
@ -89,7 +89,7 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl
|
|||
if (newChildren != null) {
|
||||
newProps.children = React.createElement(StaticHtml, {
|
||||
hydrate: needsHydration(metadata),
|
||||
value: newChildren
|
||||
value: newChildren,
|
||||
});
|
||||
}
|
||||
const vnode = React.createElement(Component, newProps);
|
||||
|
|
|
@ -10,12 +10,13 @@ function check(Component) {
|
|||
async function renderToStaticMarkup(Component, props, slotted, metadata) {
|
||||
const slots = {};
|
||||
for (const [key, value] of Object.entries(slotted)) {
|
||||
slots[key] = () => h(StaticHtml, {
|
||||
value,
|
||||
name: key === 'default' ? undefined : key,
|
||||
// Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot`
|
||||
hydrate: metadata.astroStaticSlot ? !!metadata.hydrate : true,
|
||||
});
|
||||
slots[key] = () =>
|
||||
h(StaticHtml, {
|
||||
value,
|
||||
name: key === 'default' ? undefined : key,
|
||||
// Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot`
|
||||
hydrate: metadata.astroStaticSlot ? !!metadata.hydrate : true,
|
||||
});
|
||||
}
|
||||
const app = createSSRApp({ render: () => h(Component, props, slots) });
|
||||
await setup(app);
|
||||
|
|
Loading…
Reference in a new issue