From ba157758057a8c2de89821661491d3b4a66c329e Mon Sep 17 00:00:00 2001 From: Josh Story Date: Fri, 10 Feb 2023 13:01:27 -0800 Subject: [PATCH] remove unguarded getRootNode call --- .../src/client/ReactDOMFloatClient.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js b/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js index 33d2800ec37e4..7091db0525b9f 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js +++ b/packages/react-dom-bindings/src/client/ReactDOMFloatClient.js @@ -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; @@ -111,7 +111,7 @@ export type HoistableRoot = Document | ShadowRoot; const preloadPropsMap: Map = 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`, @@ -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 @@ -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 // --------------------------------------