Module html

Module html 

Source
Expand description

Html as a value, not a string.

Ported from Phase 0’s beck-p0-core::html, which hand-wrote the output the compiler would generate. In Phase 1 it is the runtime representation the compiled view builds: the ui: macro lowers to html_el/html_text/html_attr/html_on/html_key, and those primitives build these values. The Phase 0 tests came with it unchanged, which is the point — the value semantics did not move, only who writes the code that produces them.

§4.2: “UI trees stay symbolic … a component tree that has already become DOM mutation calls cannot be server-side rendered or pre-rendered at build time.” The same value is therefore rendered three ways: to an SSR string (free first paint), to the wire encoding carried by patches, and — the point of the exercise — structurally diffed against its predecessor (crate::diff).

Every node carries a structural hash computed at construction. §5.1: “because views are signal-derived, the differ knows which subtrees can’t have changed and skips them”. Phase 0 has no signal graph, so it approximates that with an O(1) hash comparison per subtree — the same asymptotic effect, without the machinery.

Enums§

Html

Constants§

KEY_ATTR
Attribute name under which a keyed node’s key is materialised on the wire and in SSR output.

Functions§

escape_attr
Escape a string for an attribute value the shell writes rather than a view.