Skip to content

Commit

Permalink
remove unguarded getRootNode call (#26152)
Browse files Browse the repository at this point in the history
I forgot to guard the `getRootNode` call in #26106 and it fails in IE8
and old jsdom. I consolidated the implementation a bit and removed the
unguarded call
  • Loading branch information
gnoff authored Feb 10, 2023
1 parent 2de85d7 commit 64acd39
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/react-dom-bindings/src/client/ReactDOMFloatClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let lastCurrentDocument: ?Document = null;

let previousDispatcher = null;
export function prepareToRenderResources(rootContainer: Container) {
const rootNode = getRootNode(rootContainer);
const rootNode = getHoistableRoot(rootContainer);
lastCurrentDocument = getDocumentFromRoot(rootNode);

previousDispatcher = Dispatcher.current;
Expand All @@ -111,7 +111,7 @@ export type HoistableRoot = Document | ShadowRoot;
const preloadPropsMap: Map<string, PreloadProps> = new Map();

// getRootNode is missing from IE and old jsdom versions
function getRootNode(container: Container): HoistableRoot {
export function getHoistableRoot(container: Container): HoistableRoot {
// $FlowFixMe[method-unbinding]
return typeof container.getRootNode === 'function'
? /* $FlowFixMe[incompatible-return] Flow types this as returning a `Node`,
Expand All @@ -122,7 +122,7 @@ function getRootNode(container: Container): HoistableRoot {

function getCurrentResourceRoot(): null | HoistableRoot {
const currentContainer = getCurrentRootHostContainer();
return currentContainer ? getRootNode(currentContainer) : null;
return currentContainer ? getHoistableRoot(currentContainer) : null;
}

// Preloads are somewhat special. Even if we don't have the Document
Expand All @@ -148,11 +148,6 @@ function getDocumentFromRoot(root: HoistableRoot): Document {
return root.ownerDocument || root;
}

export function getHoistableRoot(container: Container): HoistableRoot {
// Flow thinks getRootNode returns Node but we know it is actualy either a Document or ShadowRoot
return ((container.getRootNode(): any): Document | ShadowRoot);
}

// --------------------------------------
// ReactDOM.Preload
// --------------------------------------
Expand Down

0 comments on commit 64acd39

Please sign in to comment.