diff --git a/packages/astro/src/internal/index.ts b/packages/astro/src/internal/index.ts index 067fe6c67..f000900de 100644 --- a/packages/astro/src/internal/index.ts +++ b/packages/astro/src/internal/index.ts @@ -33,7 +33,7 @@ async function _render(child: any): Promise { // Special: If a child is a function, call it automatically. // This lets you do {() => ...} without the extra boilerplate // of wrapping it in a function and calling it. - return await child(); + return _render(child()); } else if (typeof child === 'string') { return child; } else if (!child && child !== 0) { @@ -143,7 +143,7 @@ export async function renderSlot(result: any, slotted: string, fallback?: any) { export async function renderComponent(result: any, displayName: string, Component: unknown, _props: Record, slots?: any) { Component = await Component; - // children = await renderGenerator(children); + const children = await renderSlot(result, slots?.default); const { renderers } = result._metadata; if (Component && (Component as any).isAstroComponentFactory) { @@ -179,15 +179,15 @@ export async function renderComponent(result: any, displayName: string, Componen let renderer = null; for (const r of renderers) { - if (await r.ssr.check(Component, props, null)) { + if (await r.ssr.check(Component, props, children)) { renderer = r; } } - ({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, null)); + ({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children)); if (!hydrationDirective) { - return html; + return html.replace(/\<\/?astro-fragment\>/g, ''); } const astroId = shorthash.unique(html); diff --git a/packages/astro/test/astro-children.test.js b/packages/astro/test/astro-children.test.js index 9bb18b0fc..840c3422e 100644 --- a/packages/astro/test/astro-children.test.js +++ b/packages/astro/test/astro-children.test.js @@ -1,6 +1,3 @@ -/** - * UNCOMMENT when Component slots lands in new compiler - import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; @@ -15,7 +12,6 @@ before(async () => { await fixture.build(); }); -// TODO: waiting on Component slots describe('Component children', () => { it('Passes string children to framework components', async () => { const html = await fixture.readFile('/strings/index.html'); @@ -74,6 +70,3 @@ describe('Component children', () => { expect($svelte.children(':last-child').text().trim()).to.equal('Goodbye world'); }); }); -*/ - -it.skip('is skipped', () => {});