Skip to content

Commit 64acd39

Browse files
authored
remove unguarded getRootNode call (#26152)
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
1 parent 2de85d7 commit 64acd39

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

packages/react-dom-bindings/src/client/ReactDOMFloatClient.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ let lastCurrentDocument: ?Document = null;
8888

8989
let previousDispatcher = null;
9090
export function prepareToRenderResources(rootContainer: Container) {
91-
const rootNode = getRootNode(rootContainer);
91+
const rootNode = getHoistableRoot(rootContainer);
9292
lastCurrentDocument = getDocumentFromRoot(rootNode);
9393

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

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

123123
function getCurrentResourceRoot(): null | HoistableRoot {
124124
const currentContainer = getCurrentRootHostContainer();
125-
return currentContainer ? getRootNode(currentContainer) : null;
125+
return currentContainer ? getHoistableRoot(currentContainer) : null;
126126
}
127127

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

151-
export function getHoistableRoot(container: Container): HoistableRoot {
152-
// Flow thinks getRootNode returns Node but we know it is actualy either a Document or ShadowRoot
153-
return ((container.getRootNode(): any): Document | ShadowRoot);
154-
}
155-
156151
// --------------------------------------
157152
// ReactDOM.Preload
158153
// --------------------------------------

0 commit comments

Comments
 (0)