Skip to content

HChild

HChild = string | number | Node | null | undefined | HChild[]

Defined in: map/h.ts:23

A minimal hyperscript helper: build a detached DOM element tree declaratively, with no framework and no HTML-string parsing. It’s the un-sugared React.createElement model β€” handy for the rich content the engine tooltip option accepts ((d) => HTMLElement), or any HTML overlay.

Props are applied as plain attributes via setAttribute (so class and style are just "class" / "style" strings); null/undefined values are skipped. Children may be a string, number, Node, or a (nested) array thereof; nullish children are skipped and primitives become text nodes β€” so values are always inserted as text, never parsed as markup.

import { h } from "@mapequation/d3gl/map";
tooltip: (d) => h("div", null, [
h("div", { class: "font-semibold" }, d.name),
h("table", null, d.rows.map((r) =>
h("tr", null, [h("td", null, r.key), h("td", { class: "text-right" }, r.value)]))),
]);