docs/solutions/developer-experience/2026-05-14-slate-dom-runtime-recovery-needs-resolver-apis-not-suppress-throw.md
Slate needs two DOM bridge modes: strict APIs for direct invariant checks, and
nullable runtime APIs for browser/model projection gaps. Using suppressThrow
or local catches in runtime code makes normal browser timing look like exception
plumbing.
ReactEditor.toSlateRange(..., { suppressThrow: true })
for selection import and beforeinput reconciliation.toDOMRange failures to avoid
crashing during transient DOM gaps.tryToDOMRange style API looked tempting, but it would document the
wrong mental model.suppressThrow as the runtime contract hid errors but left the public
API vague.try* aliases would have made the API look like users should
catch exceptions for expected editor states.Keep strict helpers and add nullable resolver helpers:
editor.dom.toDOMRange(range) // strict, throws on invariant failure
editor.dom.resolveDOMRange(range) // runtime/app path, returns DOMRange | null
The implementation added resolver counterparts for DOM nodes, points, ranges, paths, event ranges, Slate nodes, Slate points, Slate ranges, and range rects. Runtime code then moved to the resolver API:
const range = ReactEditor.resolveSlateRange(editor, domSelection, {
exactMatch: false,
})
if (!range) {
return
}
Examples use the same pattern:
const rect = editor.dom.resolveRangeRect(target)
if (!rect) {
return
}
Do not keep a deprecated suppressThrow shim. resolve* is the only nullable
path; strict to* and find* helpers keep throwing.
null is the right public result for "not currently resolvable": Slate already
uses Range | null for absent selections, DOM APIs use null for unavailable
nodes/selections, and runtime code only needs a fail-closed branch.
Strict helpers still expose real misuse:
toDOMNodeRuntime helpers handle normal browser timing:
resolve* and return T | null.try* DOM bridge aliases.to* or find* helpers nullable.suppressThrow instead of carrying a deprecated compatibility option.nulltry* aliases appear on editor.dombun test:slate-browser:selection.