dom.ts — astro Source File
Architecture documentation for dom.ts, a typescript file in the astro codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8ed07f65_b5eb_2959_672d_572dd370f3b4["dom.ts"] 10d4e39f_edb6_3e34_aa93_ae1211e7da05["../types/public/internal.js"] 8ed07f65_b5eb_2959_672d_572dd370f3b4 --> 10d4e39f_edb6_3e34_aa93_ae1211e7da05 a7eea85d_ea97_57b1_9a24_f99face6a97d["./escape.js"] 8ed07f65_b5eb_2959_672d_572dd370f3b4 --> a7eea85d_ea97_57b1_9a24_f99face6a97d 624e5f97_7f83_f926_3407_b10786361e90["./slot.js"] 8ed07f65_b5eb_2959_672d_572dd370f3b4 --> 624e5f97_7f83_f926_3407_b10786361e90 f6f0048c_504d_27bf_f669_9d6d4a931037["./util.js"] 8ed07f65_b5eb_2959_672d_572dd370f3b4 --> f6f0048c_504d_27bf_f669_9d6d4a931037 style 8ed07f65_b5eb_2959_672d_572dd370f3b4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { SSRResult } from '../../../types/public/internal.js';
import { markHTMLString } from '../escape.js';
import { renderSlotToString } from './slot.js';
import { toAttributeString } from './util.js';
export function componentIsHTMLElement(Component: unknown) {
return typeof HTMLElement !== 'undefined' && HTMLElement.isPrototypeOf(Component as object);
}
export async function renderHTMLElement(
result: SSRResult,
constructor: typeof HTMLElement,
props: any,
slots: any,
): Promise<string> {
const name = getHTMLElementName(constructor);
let attrHTML = '';
for (const attr in props) {
attrHTML += ` ${attr}="${toAttributeString(await props[attr])}"`;
}
return markHTMLString(
`<${name}${attrHTML}>${await renderSlotToString(result, slots?.default)}</${name}>`,
);
}
function getHTMLElementName(constructor: typeof HTMLElement) {
const definedName = (
customElements as CustomElementRegistry & { getName(_constructor: typeof HTMLElement): string }
).getName(constructor);
if (definedName) return definedName;
const assignedName = constructor.name
.replace(/^HTML|Element$/g, '')
.replace(/[A-Z]/g, '-$&')
.toLowerCase()
.replace(/^-/, 'html-');
return assignedName;
}
Domain
Subdomains
Dependencies
- ../types/public/internal.js
- ./escape.js
- ./slot.js
- ./util.js
Source
Frequently Asked Questions
What does dom.ts do?
dom.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in dom.ts?
dom.ts defines 3 function(s): componentIsHTMLElement, getHTMLElementName, renderHTMLElement.
What does dom.ts depend on?
dom.ts imports 4 module(s): ../types/public/internal.js, ./escape.js, ./slot.js, ./util.js.
Where is dom.ts in the architecture?
dom.ts is located at packages/astro/src/runtime/server/render/dom.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/runtime/server/render).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free