chore: install prettier
This commit is contained in:
@@ -2,7 +2,7 @@ export async function renderSvg(relativePath) {
|
||||
const svgRes = await fetch(relativePath);
|
||||
const svgText = await svgRes.text();
|
||||
const parser = new DOMParser();
|
||||
const svgDoc = parser.parseFromString(svgText, 'image/svg+xml');
|
||||
const svgDoc = parser.parseFromString(svgText, "image/svg+xml");
|
||||
const svgElement = svgDoc.documentElement;
|
||||
|
||||
return svgElement;
|
||||
@@ -12,21 +12,21 @@ export function html(tag, props = {}, children = []) {
|
||||
const element = document.createElement(tag);
|
||||
|
||||
Object.entries(props).forEach(([key, value]) => {
|
||||
if (key === 'textContent' || key === 'innerHTML') {
|
||||
if (key === "textContent" || key === "innerHTML") {
|
||||
element[key] = value;
|
||||
} else if (key === 'style' && typeof value === 'object') {
|
||||
} else if (key === "style" && typeof value === "object") {
|
||||
Object.assign(element.style, value);
|
||||
} else if (key === 'class') {
|
||||
} else if (key === "class") {
|
||||
element.className = value;
|
||||
} else if (key.startsWith('on')) {
|
||||
} else if (key.startsWith("on")) {
|
||||
element.addEventListener(key.slice(2).toLowerCase(), value);
|
||||
} else {
|
||||
element.setAttribute(key, value);
|
||||
}
|
||||
});
|
||||
|
||||
children.flat().forEach(child => {
|
||||
if (typeof child === 'string') {
|
||||
children.flat().forEach((child) => {
|
||||
if (typeof child === "string") {
|
||||
element.appendChild(document.createTextNode(child));
|
||||
} else if (child instanceof Node) {
|
||||
element.appendChild(child);
|
||||
|
||||
Reference in New Issue
Block a user