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
Josh Story committed
Feb 10, 2023 at 13:35 UTC
64acd3918a26d92773d3dd451a735603ef50d3a7
1 file changed
+3
-8
packages/react-dom-bindings/src/client/ReactDOMFloatClient.js
+3
-8
@@ -88,7 +88,7 @@ let lastCurrentDocument: ?Document = null;
88
89
let previousDispatcher = null;
90
export function prepareToRenderResources(rootContainer: Container) {
91
- const rootNode = getRootNode(rootContainer);
91
+ const rootNode = getHoistableRoot(rootContainer);
92
lastCurrentDocument = getDocumentFromRoot(rootNode);
93
94
previousDispatcher = Dispatcher.current;
@@ -111,7 +111,7 @@ export type HoistableRoot = Document | ShadowRoot;
111
const preloadPropsMap: Map<string, PreloadProps> = new Map();
112
113
// getRootNode is missing from IE and old jsdom versions
114
-function getRootNode(container: Container): HoistableRoot {
114
+export function getHoistableRoot(container: Container): HoistableRoot {
115
// $FlowFixMe[method-unbinding]
116
return typeof container.getRootNode === 'function'
117
? /* $FlowFixMe[incompatible-return] Flow types this as returning a `Node`,
@@ -122,7 +122,7 @@ function getRootNode(container: Container): HoistableRoot {
122
123
function getCurrentResourceRoot(): null | HoistableRoot {
124
const currentContainer = getCurrentRootHostContainer();
125
- return currentContainer ? getRootNode(currentContainer) : null;
125
+ return currentContainer ? getHoistableRoot(currentContainer) : null;
126
}
127
128
// Preloads are somewhat special. Even if we don't have the Document
@@ -148,11 +148,6 @@ function getDocumentFromRoot(root: HoistableRoot): Document {
148
return root.ownerDocument || root;
149
}
150
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
-
151
// --------------------------------------
152
// ReactDOM.Preload
153
// --------------------------------------