fix: edge case with slotted children (#2978)

This commit is contained in:
Nate Moore 2022-04-04 01:18:07 -05:00 committed by GitHub
parent dc6e89f0a3
commit 3f0bc5af57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix edge case where default slots could be rendered too early for Astro components. Slots are now only rendered on demand.

View file

@ -150,9 +150,8 @@ export async function renderComponent(
slots: any = {}
) {
Component = await Component;
const children = await renderSlot(result, slots?.default);
if (Component === Fragment) {
const children = await renderSlot(result, slots?.default);
if (children == null) {
return children;
}
@ -197,6 +196,7 @@ Did you mean to add ${formatList(probableRendererNames.map((r) => '`' + r + '`')
throw new Error(message);
}
const children = await renderSlot(result, slots?.default);
// Call the renderers `check` hook to see if any claim this component.
let renderer: SSRLoadedRenderer | undefined;
if (metadata.hydrate !== 'only') {