(tag, props = {}, ...children)
| 76 | |
| 77 | // ---------- Tiny DOM helper ---------- |
| 78 | function h(tag, props = {}, ...children) { |
| 79 | const el = document.createElement(tag); |
| 80 | Object.entries(props).forEach(([k, v]) => { |
| 81 | if (k === "style" && typeof v === "object") Object.assign(el.style, v); |
| 82 | else if (k.startsWith("on") && typeof v === "function") el.addEventListener(k.slice(2), v); |
| 83 | else el[k] = v; |
| 84 | }); |
| 85 | for (const c of children) el.append(c && c.nodeType ? c : document.createTextNode(String(c))); |
| 86 | return el; |
| 87 | } |
| 88 | |
| 89 | function escapeHtml(s) { |
| 90 | return String(s).replace( |
no test coverage detected