(tag, props = {}, ...children)
| 51 | |
| 52 | // ---------- Small DOM helper ---------- |
| 53 | function h(tag, props = {}, ...children) { |
| 54 | const el = document.createElement(tag); |
| 55 | Object.entries(props).forEach(([k, v]) => { |
| 56 | if (k === "style" && typeof v === "object") Object.assign(el.style, v); |
| 57 | else if (k.startsWith("on") && typeof v === "function") el.addEventListener(k.slice(2), v); |
| 58 | else el[k] = v; |
| 59 | }); |
| 60 | for (const c of children) el.append(c && c.nodeType ? c : document.createTextNode(String(c))); |
| 61 | return el; |
| 62 | } |
| 63 | |
| 64 | // value type helper |
| 65 | const typing = (x) => { |
no test coverage detected