Rich text / foldkit-richtext-dom

repair

function · packages/richtext-dom/src/index.ts:645

function repair(dom: EditorDom, content: RichText.Document): EditorDom

Recovery, not domain state (§31): makes the subtree match the document again after something outside the semantic pipeline touched it — a cancelled IME composition leaves text the document never had, and a browser extension can mutate anything. A block whose rendered text and element already match is left alone and the same EditorDom comes back, so nothing is rebuilt in the normal case; rendering each run once to compare it is the price of a check that cannot drift, paid when a composition ends rather than on every edit.