normalize = svg => {
const node = svg.cloneNode();
for (const polyline of svg.querySelectorAll("polyline")) {
node.appendChild(htl.svg`<path d="M ${polyline.getAttribute("points")}" />`);
}
for (const polygon of svg.querySelectorAll("polygon")) {
node.appendChild(htl.svg`<path d="M ${polygon.getAttribute("points")} Z" />`);
}
for (const line of svg.querySelectorAll("line")) {
const points = ["x1", "y1", "x2", "y2"].map(attr => line.getAttribute(attr));
node.appendChild(htl.svg`<path d="M ${points}" />`);
}
for (const rect of svg.querySelectorAll("rect")) {
const [x, y, width, height] = ["x", "y", "width", "height"].map(attr => rect.getAttribute(attr));
node.appendChild(htl.svg`<path d="M ${x} ${y} h ${width} v ${height} h ${-width} z" />`);
}
for (const circle of svg.querySelectorAll("circle")) {
const [cx, cy, r] = ["cx", "cy", "r"].map(attr => circle.getAttribute(attr));
const x1 = cx - r, y1 = cy;
node.appendChild(htl.svg`<path d="M ${x1} ${y1} a ${r} ${r} 0 1 1 ${2 * r} 0 ${r} ${r} 0 1 1 ${-2 * r} 0 Z" />`);
}
for (const path of svg.querySelectorAll("path")) {
node.appendChild(htl.svg`<path d="${path.getAttribute("d")}" />`)
}
return node;
}