import {AttrValue} from "../types.js" import {attrSet} from "../attrs/parts/attr-fns.js" export function elmer(tagName: string) { return new Elmer(tagName) } export class Elmer { #attrs = new Map() #children: (Node | string)[] = [] constructor(public tagName: string) {} attr(key: string, value: AttrValue = true) { this.#attrs.set(key, value) return this } attrs(record: Record) { for (const [key, value] of Object.entries(record)) this.attr(key, value) return this } children(...elements: (Node | string)[]) { this.#children.push(...elements) return this } done() { const element = document.createElement(this.tagName) attrSet.entries(element, this.#attrs) element.append(...this.#children) return element as E } }