Skip to content

Commit

Permalink
Fix issue rendering content within HTMLElement (#2506)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Neal committed Jan 31, 2022
1 parent 4ddb44c commit 187d512
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-suns-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix an issue rendering content within HTMLElement
9 changes: 2 additions & 7 deletions packages/astro/src/runtime/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export async function renderAstroComponent(component: InstanceType<typeof AstroC
return template;
}

export async function renderHTMLElement(result: SSRResult, constructor: typeof HTMLElement, props: any, children: any) {
export async function renderHTMLElement(result: SSRResult, constructor: typeof HTMLElement, props: any, slots: any) {
const name = getHTMLElementName(constructor);

let attrHTML = '';
Expand All @@ -451,12 +451,7 @@ export async function renderHTMLElement(result: SSRResult, constructor: typeof H
attrHTML += ` ${attr}="${toAttributeString(await props[attr])}"`;
}

children = await children;
children = children == null ? children : '';

const html = `<${name}${attrHTML}>${children}</${name}>`;

return html;
return `<${name}${attrHTML}>${await renderSlot(result, slots?.default)}</${name}>`;
}

function getHTMLElementName(constructor: typeof HTMLElement) {
Expand Down

0 comments on commit 187d512

Please sign in to comment.