Skip to content

Commit

Permalink
fix: render valid xml document
Browse files Browse the repository at this point in the history
  • Loading branch information
Wykerd committed Aug 10, 2023
1 parent 6fda48d commit f822e5c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/utils/DashUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function createTextElement(text: string): DashNode {
};
}

export async function renderToString(element: DashNode): Promise<string> {
export async function renderElementToString(element: DashNode): Promise<string> {
if (element.type === 'TEXT_ELEMENT')
return escapeXMLString(typeof element.props.nodeValue === 'string' ? element.props.nodeValue : '');

Expand All @@ -92,6 +92,12 @@ export async function renderToString(element: DashNode): Promise<string> {
return `${dom}/>`;
}

export async function renderToString(root: DashNode) {
const dom = await renderElementToString(root);

return `<?xml version="1.0" encoding="utf-8"?>${dom}`;
}

export function Fragment(props: DashProps) {
return props.children;
}

0 comments on commit f822e5c

Please sign in to comment.