feat: implement base of diagnostics

This commit is contained in:
divocat
2025-10-11 23:09:31 +03:00
parent 5486dfb0a4
commit 4334643e8e
18 changed files with 1518 additions and 12 deletions

View File

@@ -0,0 +1,18 @@
export function svgEl<K extends keyof SVGElementTagNameMap>(
tag: K,
attrs: Partial<Record<string, string | number>> = {},
children: (SVGElement | null | undefined)[] = [],
): SVGElementTagNameMap[K] {
const NS = 'http://www.w3.org/2000/svg';
const el = document.createElementNS(NS, tag);
for (const [k, v] of Object.entries(attrs)) {
if (v != null) el.setAttribute(k, String(v));
}
(Array.isArray(children) ? children : [children])
.filter(Boolean)
.forEach((ch) => el.appendChild(ch as SVGElement));
return el;
}