From 8623ab1e7218c966f5e44539f03a52bd3d508769 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 21 Jun 2022 10:07:15 -0500 Subject: [PATCH] fix: render unmatched custom element children --- packages/astro/src/runtime/server/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts index 94776c3545b14..d916d340eeef5 100644 --- a/packages/astro/src/runtime/server/index.ts +++ b/packages/astro/src/runtime/server/index.ts @@ -316,11 +316,12 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr // This is a custom element without a renderer. Because of that, render it // as a string and the user is responsible for adding a script tag for the component definition. if (!html && typeof Component === 'string') { + const childSlots = Object.values(children).join(''); html = await renderAstroComponent( await render`<${Component}${internalSpreadAttributes(props)}${markHTMLString( - (children == null || children?.default == '') && voidElementNames.test(Component) + childSlots === '' && voidElementNames.test(Component) ? `/>` - : `>${children == null ? '' : children}` + : `>${childSlots}` )}` ); } @@ -346,7 +347,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr result._metadata.needsHydrationStyles = true; // Render template if not all astro fragments are provided. - const unrenderedSlots: string[] = []; + let unrenderedSlots: string[] = []; if (Object.keys(children).length > 0) { for (const key of Object.keys(children)) { if (!html.includes(key === 'default' ? `` : ``)) {