<!--
  Note: if the issue is about documentation or the website, please file it at:
  https://github.com/reactjs/reactjs.org/issues/new
-->

**Do you want to request a *feature* or report a *bug*?**

bug

**What is the current behavior?**

When transitioning from a state having an iframe inside a component to a state without that said iframe, we have an error at `setOffsets(node, offsets)` because `node.ownerDocument.defaultView` being `null`

**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:**

Working on it

**What is the expected behavior?**

Should not break

**Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?**

Affected since this 16.5.0, coming from this PR exactly https://github.com/facebook/react/pull/12037/files#diff-26d90cba6ee597ef475fa80dcf76ae1d

`getOffsets` as a check on `ownerDocument.default` fallbacks to `window`, but `setOffsets` does not.

Is there a reason why?
try {
    
    anchorNode.nodeType;
    focusNode.nodeType;
    
  } catch (e) {
    return null;
  }
  return getModernOffsetsFromPoints(
    outerNode,
    anchorNode,
    anchorOffset,
    focusNode,
    focusOffset,
  );
}
/**
 * Returns {start, end} where `start` is the character/codepoint index of
 * (anchorNode, anchorOffset) within the textContent of `outerNode`, and
 * `end` is the index of (focusNode, focusOffset).
 *
 * Returns null if you pass in garbage input but we should probably just crash.
 *
 * Exported only for testing.
 */
export function getModernOffsetsFromPoints(