mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
[ci] format
This commit is contained in:
parent
904131aec3
commit
bf2320edb6
3 changed files with 11 additions and 10 deletions
|
@ -9,6 +9,7 @@ import type {
|
||||||
SSRLoadedRenderer,
|
SSRLoadedRenderer,
|
||||||
SSRResult,
|
SSRResult,
|
||||||
} from '../../@types/astro';
|
} from '../../@types/astro';
|
||||||
|
import { isHTMLString } from '../../runtime/server/escape.js';
|
||||||
import {
|
import {
|
||||||
renderSlotToString,
|
renderSlotToString,
|
||||||
stringifyChunk,
|
stringifyChunk,
|
||||||
|
@ -18,7 +19,6 @@ import { renderJSX } from '../../runtime/server/jsx.js';
|
||||||
import { AstroCookies } from '../cookies/index.js';
|
import { AstroCookies } from '../cookies/index.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError, AstroErrorData } from '../errors/index.js';
|
||||||
import { warn, type LogOptions } from '../logger/core.js';
|
import { warn, type LogOptions } from '../logger/core.js';
|
||||||
import { isHTMLString } from '../../runtime/server/escape.js';
|
|
||||||
|
|
||||||
const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
const clientAddressSymbol = Symbol.for('astro.clientAddress');
|
||||||
const responseSentSymbol = Symbol.for('astro.responseSent');
|
const responseSentSymbol = Symbol.for('astro.responseSent');
|
||||||
|
@ -111,12 +111,11 @@ class Slots {
|
||||||
// Astro
|
// Astro
|
||||||
const expression = getFunctionExpression(component);
|
const expression = getFunctionExpression(component);
|
||||||
if (expression) {
|
if (expression) {
|
||||||
const slot = async () => isHTMLString(await expression) ? expression : expression(...args)
|
const slot = async () =>
|
||||||
|
isHTMLString(await expression) ? expression : expression(...args);
|
||||||
return await renderSlotToString(result, slot).then((res) => {
|
return await renderSlotToString(result, slot).then((res) => {
|
||||||
return res != null ? String(res) : res
|
return res != null ? String(res) : res;
|
||||||
}
|
});
|
||||||
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
// JSX
|
// JSX
|
||||||
if (typeof component === 'function') {
|
if (typeof component === 'function') {
|
||||||
|
|
|
@ -7,7 +7,9 @@ import { renderChild } from './any.js';
|
||||||
|
|
||||||
type RenderTemplateResult = ReturnType<typeof renderTemplate>;
|
type RenderTemplateResult = ReturnType<typeof renderTemplate>;
|
||||||
export type ComponentSlots = Record<string, ComponentSlotValue>;
|
export type ComponentSlots = Record<string, ComponentSlotValue>;
|
||||||
export type ComponentSlotValue = (result: SSRResult) => RenderTemplateResult | Promise<RenderTemplateResult>;
|
export type ComponentSlotValue = (
|
||||||
|
result: SSRResult
|
||||||
|
) => RenderTemplateResult | Promise<RenderTemplateResult>;
|
||||||
|
|
||||||
const slotString = Symbol.for('astro:slot-string');
|
const slotString = Symbol.for('astro:slot-string');
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ describe('set:html', () => {
|
||||||
expect(res.status).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
let html = await res.text();
|
let html = await res.text();
|
||||||
expect(html).include('Test');
|
expect(html).include('Test');
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Build', () => {
|
describe('Build', () => {
|
||||||
|
@ -87,6 +87,6 @@ describe('set:html', () => {
|
||||||
it('test Fragment when Fragment is as a slot', async () => {
|
it('test Fragment when Fragment is as a slot', async () => {
|
||||||
let res = await fixture.readFile('/children/index.html');
|
let res = await fixture.readFile('/children/index.html');
|
||||||
expect(res).include('Test');
|
expect(res).include('Test');
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue