Expand description
Mutable scripted-DOM provider.
ScriptedDom is the mutable sibling of serval-static-dom’s StaticDocument:
a NodeId-keyed arena that implements LayoutDom (read) and LayoutDomMut
(mutate), recording each structural change as a DomMutation for
serval-layout’s scheduler to translate into invalidation. The arena owns the
node data; JS reflectors bridge back to it by NodeId (via
script-engine-api’s make_reflector/reflector_data), so the engine never
owns DOM data.
Scope (2026-05-23): structural mutation + the mutation stream. The reflector
bridge wiring and the DomMutation → serval-layout invalidation loop are the next
pass (they need the script-runtime-api host layer and serval-layout’s
scheduler). set_inner_html is deferred — it needs html5ever fragment parsing.
Structs§
- NodeId
- Opaque node identity: a stable index into the arena (slots are never reused, so ids stay valid for the document’s lifetime).
- Pins
- A set of node ids to treat as extra mark roots for
ScriptedDom::collect— nodes the document tree no longer reaches but that must survive anyway. The host pins a node while script can still reach it (it holds a reflector), so a pinned orphan and its whole connected component are spared; unpinning it makes it collectable. The DOM only sees a pin set; the host’s word for these is “reflector pins” (itpins on minting a reflector andretires the ones the engine reports dead). Engine-agnostic — it traffics only inNodeId, naming no engine type. - Scripted
Dom - A mutable DOM arena. Nodes live in a prunable [
NodeStore] keyed by a monotonic id; a pruned id is “gone” (ids are never reused). Memory is bounded to live nodes bycollect(G3), not to every node ever created.