ianstormtaylor/slate · error · Error

Cannot resolve a DOM point from Slate point: ${Scrubber.stri

Error message

Cannot resolve a DOM point from Slate point: ${Scrubber.stringify(point)}

What it means

Thrown by DOMEditor.toDOMPoint when no DOM text node and offset can be found corresponding to a Slate point. This happens when the point references text that has no rendered DOM counterpart, or the point is out of bounds after the document changed.

Source

Thrown at packages/slate-dom/src/plugin/dom-editor.ts:638

          // selection to return incorrect zero values (https://bugs.chromium.org/p/chromium/issues/detail?id=435438)
          // which will cause issues when scrolling to it.
          domText instanceof DOMText ? domText : nextText,
          nextText.textContent?.startsWith('\uFEFF') ? 1 : 0,
        ]
        break
      }

      if (point.offset <= end) {
        const offset = Math.min(length, Math.max(0, point.offset - start))
        domPoint = [domNode, offset]
        break
      }

      start = end
    }

    if (!domPoint) {
      throw new Error(
        `Cannot resolve a DOM point from Slate point: ${Scrubber.stringify(
          point
        )}`
      )
    }

    return domPoint
  },

  toDOMRange: (editor, range) => {
    const { anchor, focus } = range
    const isBackward = Range.isBackward(range)
    const domAnchor = DOMEditor.toDOMPoint(editor, anchor)
    const domFocus = Range.isCollapsed(range)
      ? domAnchor
      : DOMEditor.toDOMPoint(editor, focus)

    const window = DOMEditor.getWindow(editor)

View on GitHub (pinned to 72a37c701e)

Solutions

  1. Validate the point with Editor.has(editor, point) (or Node.has on the path) before converting
  2. Recompute the selection after edits rather than reusing stale points
  3. Defer conversion until after render commits
  4. Ensure the node is actually rendered (not virtualized away) before asking for its DOM point

Example fix

// before
const domPoint = DOMEditor.toDOMPoint(editor, savedPoint)
// after
const p = savedPoint
if (Editor.has(editor, p)) {
  const domPoint = DOMEditor.toDOMPoint(editor, p)
}
Defensive patterns

Strategy: validation

Validate before calling

import { Editor } from 'slate'
if (Editor.has(editor, point)) {
  const domPoint = DOMEditor.toDOMPoint(editor, point)
}

Type guard

const isPointInEditor = (editor: Editor, p: Point): boolean => {
  try { return Editor.has(editor, p) } catch { return false }
}

Try / catch

try { DOMEditor.toDOMPoint(editor, point) } catch (e) { if (/Cannot resolve a DOM point/.test(e.message)) recompute selection; else throw e }

Prevention

When it happens

Trigger: Calling toDOMPoint with a point whose path no longer exists, an offset past the end of a text node, a point in a node rendered by a placeholder (e.g. virtualized), or while the DOM is mid-flush.

Common situations: Restoring a saved selection after the document was normalized/changed; scrolling virtualized content so the text is unmounted; racing selection restoration against React commits.

Related errors


AI-assisted analysis of ianstormtaylor/slate@72a37c701e (2026-08-27). Data as JSON: /api/errors/a08aaf67342dcbd8. Report an issue: GitHub.