diff --git a/packages/astro/src/core/render/result.ts b/packages/astro/src/core/render/result.ts index 22ca5bc809..ede30256e1 100644 --- a/packages/astro/src/core/render/result.ts +++ b/packages/astro/src/core/render/result.ts @@ -9,6 +9,7 @@ import type { SSRLoadedRenderer, SSRResult, } from '../../@types/astro'; +import { isHTMLString } from '../../runtime/server/escape.js'; import { renderSlotToString, stringifyChunk, @@ -18,7 +19,6 @@ import { renderJSX } from '../../runtime/server/jsx.js'; import { AstroCookies } from '../cookies/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; import { warn, type LogOptions } from '../logger/core.js'; -import { isHTMLString } from '../../runtime/server/escape.js'; const clientAddressSymbol = Symbol.for('astro.clientAddress'); const responseSentSymbol = Symbol.for('astro.responseSent'); @@ -111,12 +111,11 @@ class Slots { // Astro const expression = getFunctionExpression(component); if (expression) { - const slot = async () => isHTMLString(await expression) ? expression : expression(...args) - return await renderSlotToString(result, slot).then((res) =>{ - return res != null ? String(res) : res - } - - ); + const slot = async () => + isHTMLString(await expression) ? expression : expression(...args); + return await renderSlotToString(result, slot).then((res) => { + return res != null ? String(res) : res; + }); } // JSX if (typeof component === 'function') { diff --git a/packages/astro/src/runtime/server/render/slot.ts b/packages/astro/src/runtime/server/render/slot.ts index 1dfe2f5d96..09a8ff39c4 100644 --- a/packages/astro/src/runtime/server/render/slot.ts +++ b/packages/astro/src/runtime/server/render/slot.ts @@ -7,7 +7,9 @@ import { renderChild } from './any.js'; type RenderTemplateResult = ReturnType; export type ComponentSlots = Record; -export type ComponentSlotValue = (result: SSRResult) => RenderTemplateResult | Promise; +export type ComponentSlotValue = ( + result: SSRResult +) => RenderTemplateResult | Promise; const slotString = Symbol.for('astro:slot-string'); diff --git a/packages/astro/test/set-html.test.js b/packages/astro/test/set-html.test.js index dab80d48cf..caffb3fda8 100644 --- a/packages/astro/test/set-html.test.js +++ b/packages/astro/test/set-html.test.js @@ -40,7 +40,7 @@ describe('set:html', () => { expect(res.status).to.equal(200); let html = await res.text(); expect(html).include('Test'); - }) + }); }); describe('Build', () => { @@ -87,6 +87,6 @@ describe('set:html', () => { it('test Fragment when Fragment is as a slot', async () => { let res = await fixture.readFile('/children/index.html'); expect(res).include('Test'); - }) + }); }); });