Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unguarded getRootNode call #26152

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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