/** * Applies `bindings` to `root` from `snapshot`. * * Idempotent: applying the same snapshot twice writes the same values, so this is * safe to call on every kernel update. * * @param {ParentNode} root * @param {ReadonlyArray} bindings * @param {unknown} snapshot * @returns {ApplyResult} */ export function applyBindings(root: ParentNode, bindings: ReadonlyArray, snapshot: unknown): ApplyResult; /** * The applier — deliberately the least capable module in the codebase. * * It takes a binding table and a kernel snapshot and writes values into the * design's markup. The entire surface is `switch (binding.as.kind)` over three * cases, and none of them can reach appearance: * * text -> `textContent` (never `innerHTML`: no markup can be injected) * attr -> `setAttribute` (allowlisted names only: no class/style/id) * presence -> the design's own state attribute * * There is no branch that writes `className`, `style`, `classList`, or that * creates or removes an element. That absence is the mechanism: it is what makes * "integration cannot change the design" a property of the code rather than a * rule someone has to remember. Adding such a branch is the one change reviewers * of this package must refuse. */ /** @import { AllowedAttribute, Binding } from "./binding-types.js" */ /** * Attribute names the applier will write. Mirrors `AllowedAttribute` at runtime. * @type {ReadonlySet} */ export const ALLOWED_ATTRIBUTES: ReadonlySet; export type ApplyResult = { /** * Bindings whose anchor resolved and whose value was written. */ applied: number; /** * Anchors that matched nothing in the live * DOM. Non-fatal at runtime (a chrome element may legitimately not be mounted yet) but * `verify-drop.mjs` treats the same condition as a BUILD failure against the drop, * which is where it matters. */ unresolved: ReadonlyArray; /** * Sources absent from the snapshot — the * value is left as the design shipped it. */ missingSources: ReadonlyArray; }; import type { Binding } from "./binding-types.js"; import type { AllowedAttribute } from "./binding-types.js";