Learn / Who changes state

Presentation state is not a fact

DOM geometry — element bounding boxes, scroll offsets, caret positions inside an input — changes on every pointer move or scroll frame. Putting DOM measurements into the Model fires a Message and full view pass on every pixel of movement for values no transition reads.

Use this test to decide where state belongs: is it replayed, stored, sent over the wire, or read by update to decide a Message?

  • If yes, it is an application fact and belongs in the Model.
  • If no, it is presentation and belongs in a DOM Behavior or Mount.

Examples from the Foldkit Plus widgets:

  • Selection vs. selection box: A page builder's selected node id is a fact (Delete reads it, URLs encode it), so it lives in the Model. The bounding rectangle drawn around that node is measured directly by Measure (foldkit-primitives/dom) and written as CSS custom properties with zero Messages.
  • Form draft vs. caret position: Unparsed text in a form field is a fact because submit validates it; the cursor offset inside that <input> stays in the DOM.
  • Hovered row across panels: When hovering a layer row highlights a node on another canvas, route hover through a Message into the Model. Call settle before saving so stale hover state is cleared.

Next