UI libraries describe the page as plain objects (what JSX compiles to) and turn those objects into real DOM nodes. Writing that step yourself shows what every prop really becomes: an attribute, a property, a listener, or a style, and why SVG needs special care.
Write render(description) in render.js. It returns new DOM nodes; it does not put them in the page.
functionrender(description) // returns a Nodedescription = {type: "button", // a tag name, or a function (a component)props: { className: "btn", onClick: save }, // optionalchildren: ["Save"], // optional};
A child is a description, a string, a number, an array of children, or null, undefined, true or false.
A string or a number renders as a text node (0 renders as "0").
A description with a string type renders as that element; missing props and children mean none.
Props become attributes with string values, with these exceptions:
className sets class, and htmlFor sets for.
true sets an empty attribute; false, null and undefined set nothing.
style as an object sets inline styles (camelCase names, and custom properties that start with --); as a string it is the style attribute.
A prop that starts with on and holds a function adds an event listener: onClick listens for click, onKeyDown for keydown. An on prop that is not a function is ignored.
value and checked are set as properties, so a field shows them.
key is not rendered.
Children are rendered in order and appended. null, undefined, true and false render nothing; arrays of children are flattened at any depth.
Text is always text: markup in a string never becomes elements.
An array renders as a DocumentFragment; null, undefined or a boolean renders as an empty DocumentFragment.
svg and every element inside it are created in the SVG namespace (http://www.w3.org/2000/svg), with attribute names kept as written (viewBox). Elements outside it are HTML.
When type is a function, it is called with the props plus children, and what it returns is rendered (it may return null).
Any other type (missing, empty, a number, an object) throws a TypeError.
Each call creates new nodes and does not change the description.