Skip to content

Commit

Permalink
remove unguarded getRootNode call
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Feb 10, 2023
1 parent 2de85d7 commit ba15775
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 ba15775

Please sign in to comment.