[ci] format
This commit is contained in:
parent
87a7cf48e7
commit
f4bca41a2d
4 changed files with 16 additions and 14 deletions
|
@ -4,9 +4,9 @@ import { SlotString } from './slot.js';
|
|||
|
||||
export async function* renderChild(child: any): AsyncIterable<any> {
|
||||
child = await child;
|
||||
if(child instanceof SlotString) {
|
||||
if(child.instructions) {
|
||||
yield * child.instructions;
|
||||
if (child instanceof SlotString) {
|
||||
if (child.instructions) {
|
||||
yield* child.instructions;
|
||||
}
|
||||
yield child;
|
||||
} else if (child instanceof HTMLString) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import { HTMLBytes, markHTMLString } from '../escape.js';
|
|||
import { extractDirectives, generateHydrateScript } from '../hydration.js';
|
||||
import { serializeProps } from '../serialize.js';
|
||||
import { shorthash } from '../shorthash.js';
|
||||
import { renderSlot, renderSlots } from './slot.js';
|
||||
import {
|
||||
isAstroComponentFactory,
|
||||
renderAstroComponent,
|
||||
|
@ -14,6 +13,7 @@ import {
|
|||
} from './astro.js';
|
||||
import { Fragment, Renderer, stringifyChunk } from './common.js';
|
||||
import { componentIsHTMLElement, renderHTMLElement } from './dom.js';
|
||||
import { renderSlot, renderSlots } from './slot.js';
|
||||
import { formatList, internalSpreadAttributes, renderElement, voidElementNames } from './util.js';
|
||||
|
||||
const rendererAliases = new Map([['solid', 'solid-js']]);
|
||||
|
@ -70,7 +70,9 @@ export async function renderComponent(
|
|||
case 'html': {
|
||||
const { slotInstructions, children } = await renderSlots(result, slots);
|
||||
const html = (Component as any).render({ slots: children });
|
||||
const hydrationHtml = slotInstructions ? slotInstructions.map(instr => stringifyChunk(result, instr)).join('') : '';
|
||||
const hydrationHtml = slotInstructions
|
||||
? slotInstructions.map((instr) => stringifyChunk(result, instr)).join('')
|
||||
: '';
|
||||
return markHTMLString(hydrationHtml + html);
|
||||
}
|
||||
|
||||
|
@ -328,8 +330,8 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
|
|||
}
|
||||
|
||||
async function* renderAll() {
|
||||
if(slotInstructions) {
|
||||
yield * slotInstructions;
|
||||
if (slotInstructions) {
|
||||
yield* slotInstructions;
|
||||
}
|
||||
yield { type: 'directive', hydration, result };
|
||||
yield markHTMLString(renderElement('astro-island', island, false));
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { renderTemplate } from './astro.js';
|
||||
|
||||
export { renderSlot } from './slot.js';
|
||||
export { renderAstroComponent, renderTemplate, renderToString } from './astro.js';
|
||||
export { Fragment, Renderer, stringifyChunk } from './common.js';
|
||||
export { renderComponent } from './component.js';
|
||||
export { renderHTMLElement } from './dom.js';
|
||||
export { maybeRenderHead, renderHead } from './head.js';
|
||||
export { renderPage } from './page.js';
|
||||
export { renderSlot } from './slot.js';
|
||||
export type { RenderInstruction } from './types';
|
||||
export { addAttribute, defineScriptVars, voidElementNames } from './util.js';
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import type { RenderInstruction } from './types.js';
|
||||
import type { SSRResult } from '../../../@types/astro.js';
|
||||
import type { RenderInstruction } from './types.js';
|
||||
|
||||
import { renderChild } from './any.js';
|
||||
import { HTMLString, markHTMLString } from '../escape.js';
|
||||
import { renderChild } from './any.js';
|
||||
|
||||
export class SlotString extends HTMLString {
|
||||
public instructions: null | RenderInstruction[];
|
||||
|
@ -19,7 +19,7 @@ export async function renderSlot(_result: any, slotted: string, fallback?: any):
|
|||
let instructions: null | RenderInstruction[] = null;
|
||||
for await (const chunk of iterator) {
|
||||
if ((chunk as any).type === 'directive') {
|
||||
if(instructions === null) {
|
||||
if (instructions === null) {
|
||||
instructions = [];
|
||||
}
|
||||
instructions.push(chunk);
|
||||
|
@ -33,7 +33,7 @@ export async function renderSlot(_result: any, slotted: string, fallback?: any):
|
|||
}
|
||||
|
||||
interface RenderSlotsResult {
|
||||
slotInstructions: null | RenderInstruction[],
|
||||
slotInstructions: null | RenderInstruction[];
|
||||
children: Record<string, string>;
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ export async function renderSlots(result: SSRResult, slots: any = {}): Promise<R
|
|||
await Promise.all(
|
||||
Object.entries(slots).map(([key, value]) =>
|
||||
renderSlot(result, value as string).then((output: any) => {
|
||||
if(output.instructions) {
|
||||
if(slotInstructions === null) {
|
||||
if (output.instructions) {
|
||||
if (slotInstructions === null) {
|
||||
slotInstructions = [];
|
||||
}
|
||||
slotInstructions.push(...output.instructions);
|
||||
|
|
Loading…
Reference in a new issue