diff --git a/packages/react-dom/src/client/ReactDOMSelection.js b/packages/react-dom/src/client/ReactDOMSelection.js index 00181336a6053..9f247af15b4f5 100644 --- a/packages/react-dom/src/client/ReactDOMSelection.js +++ b/packages/react-dom/src/client/ReactDOMSelection.js @@ -152,7 +152,7 @@ export function getModernOffsetsFromPoints( */ export function setOffsets(node, offsets) { const doc = node.ownerDocument || document; - const win = doc ? doc.defaultView : window; + const win = (doc && doc.defaultView) || window; const selection = win.getSelection(); const length = node.textContent.length; let start = Math.min(offsets.start, length);