diff --git a/packages/react-dom-bindings/src/client/ReactInputSelection.js b/packages/react-dom-bindings/src/client/ReactInputSelection.js index 0f3dfe11cd9f9..36cdc554f0f44 100644 --- a/packages/react-dom-bindings/src/client/ReactInputSelection.js +++ b/packages/react-dom-bindings/src/client/ReactInputSelection.js @@ -57,7 +57,12 @@ function isSameOriginFrame(iframe) { } function getActiveElementDeep(containerInfo) { - let win = containerInfo?.ownerDocument?.defaultView ?? window; + let win = + containerInfo != null && + containerInfo.ownerDocument != null && + containerInfo.ownerDocument.defaultView != null + ? containerInfo.ownerDocument.defaultView + : window; let element = getActiveElement(win.document); while (element instanceof win.HTMLIFrameElement) { if (isSameOriginFrame(element)) {