Skip to content

Commit

Permalink
remove unguarded getRootNode call (#26152)
Browse files Browse the repository at this point in the history
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

DiffTrain build for [64acd39](64acd39)
[View git log for this commit](https://github.com/facebook/react/commits/64acd3918a26d92773d3dd451a735603ef50d3a7)
  • Loading branch information
gnoff committed Feb 10, 2023
1 parent c7ad6cb commit 427f9d9
Show file tree
Hide file tree
Showing 28 changed files with 96 additions and 104 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2de85d7c712ff0f052d9c92f8129ed476f8ce4d8
64acd3918a26d92773d3dd451a735603ef50d3a7
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2de85d7c712ff0f052d9c92f8129ed476f8ce4d8
64acd3918a26d92773d3dd451a735603ef50d3a7
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-classic-2de85d7c7-20230210";
var ReactVersion = "18.3.0-www-classic-64acd3918-20230210";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-modern-2de85d7c7-20230210";
var ReactVersion = "18.3.0-www-modern-64acd3918-20230210";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,4 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-2de85d7c7-20230210";
exports.version = "18.3.0-www-classic-64acd3918-20230210";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,4 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-2de85d7c7-20230210";
exports.version = "18.3.0-www-modern-64acd3918-20230210";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-2de85d7c7-20230210";
exports.version = "18.3.0-www-classic-64acd3918-20230210";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-2de85d7c7-20230210";
exports.version = "18.3.0-www-modern-64acd3918-20230210";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-classic-2de85d7c7-20230210";
var ReactVersion = "18.3.0-www-classic-64acd3918-20230210";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-modern-2de85d7c7-20230210";
var ReactVersion = "18.3.0-www-modern-64acd3918-20230210";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactART-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9844,7 +9844,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-classic-2de85d7c7-20230210",
version: "18.3.0-www-classic-64acd3918-20230210",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1318 = {
Expand Down Expand Up @@ -9875,7 +9875,7 @@ var internals$jscomp$inline_1318 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-2de85d7c7-20230210"
reconcilerVersion: "18.3.0-next-64acd3918-20230210"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1319 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -9509,7 +9509,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-modern-2de85d7c7-20230210",
version: "18.3.0-www-modern-64acd3918-20230210",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1309 = {
Expand Down Expand Up @@ -9540,7 +9540,7 @@ var internals$jscomp$inline_1309 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-2de85d7c7-20230210"
reconcilerVersion: "18.3.0-next-64acd3918-20230210"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1310 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
13 changes: 4 additions & 9 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9298,7 +9298,7 @@ var Dispatcher = Internals.Dispatcher;
var lastCurrentDocument = null;
var previousDispatcher = null;
function prepareToRenderResources(rootContainer) {
var rootNode = getRootNode(rootContainer);
var rootNode = getHoistableRoot(rootContainer);
lastCurrentDocument = getDocumentFromRoot(rootNode);
previousDispatcher = Dispatcher.current;
Dispatcher.current = ReactDOMClientDispatcher;
Expand All @@ -9317,7 +9317,7 @@ var ReactDOMClientDispatcher = {

var preloadPropsMap = new Map(); // getRootNode is missing from IE and old jsdom versions

function getRootNode(container) {
function getHoistableRoot(container) {
// $FlowFixMe[method-unbinding]
return typeof container.getRootNode === "function"
? /* $FlowFixMe[incompatible-return] Flow types this as returning a `Node`,
Expand All @@ -9328,7 +9328,7 @@ function getRootNode(container) {

function getCurrentResourceRoot() {
var currentContainer = getCurrentRootHostContainer();
return currentContainer ? getRootNode(currentContainer) : null;
return currentContainer ? getHoistableRoot(currentContainer) : null;
} // Preloads are somewhat special. Even if we don't have the Document
// used by the root that is rendering a component trying to insert a preload
// we can still seed the file cache by doing the preload on any document we have
Expand All @@ -9352,11 +9352,6 @@ function getDocumentForPreloads() {

function getDocumentFromRoot(root) {
return root.ownerDocument || root;
}

function getHoistableRoot(container) {
// Flow thinks getRootNode returns Node but we know it is actualy either a Document or ShadowRoot
return container.getRootNode();
} // --------------------------------------
// ReactDOM.Preload
// --------------------------------------
Expand Down Expand Up @@ -41950,7 +41945,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-classic-2de85d7c7-20230210";
var ReactVersion = "18.3.0-www-classic-64acd3918-20230210";

function createPortal(
children,
Expand Down
13 changes: 4 additions & 9 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -14037,7 +14037,7 @@ var Dispatcher = Internals.Dispatcher;
var lastCurrentDocument = null;
var previousDispatcher = null;
function prepareToRenderResources(rootContainer) {
var rootNode = getRootNode(rootContainer);
var rootNode = getHoistableRoot(rootContainer);
lastCurrentDocument = getDocumentFromRoot(rootNode);
previousDispatcher = Dispatcher.current;
Dispatcher.current = ReactDOMClientDispatcher;
Expand All @@ -14056,7 +14056,7 @@ var ReactDOMClientDispatcher = {

var preloadPropsMap = new Map(); // getRootNode is missing from IE and old jsdom versions

function getRootNode(container) {
function getHoistableRoot(container) {
// $FlowFixMe[method-unbinding]
return typeof container.getRootNode === "function"
? /* $FlowFixMe[incompatible-return] Flow types this as returning a `Node`,
Expand All @@ -14067,7 +14067,7 @@ function getRootNode(container) {

function getCurrentResourceRoot() {
var currentContainer = getCurrentRootHostContainer();
return currentContainer ? getRootNode(currentContainer) : null;
return currentContainer ? getHoistableRoot(currentContainer) : null;
} // Preloads are somewhat special. Even if we don't have the Document
// used by the root that is rendering a component trying to insert a preload
// we can still seed the file cache by doing the preload on any document we have
Expand All @@ -14091,11 +14091,6 @@ function getDocumentForPreloads() {

function getDocumentFromRoot(root) {
return root.ownerDocument || root;
}

function getHoistableRoot(container) {
// Flow thinks getRootNode returns Node but we know it is actualy either a Document or ShadowRoot
return container.getRootNode();
} // --------------------------------------
// ReactDOM.Preload
// --------------------------------------
Expand Down Expand Up @@ -41674,7 +41669,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-modern-2de85d7c7-20230210";
var ReactVersion = "18.3.0-www-modern-64acd3918-20230210";

function createPortal(
children,
Expand Down
18 changes: 10 additions & 8 deletions compiled/facebook-www/ReactDOM-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1961,14 +1961,14 @@ var Dispatcher = Internals.Dispatcher,
previousDispatcher = null,
ReactDOMClientDispatcher = { preload: preload, preinit: preinit },
preloadPropsMap = new Map();
function getRootNode(container) {
function getHoistableRoot(container) {
return "function" === typeof container.getRootNode
? container.getRootNode()
: container.ownerDocument;
}
function getCurrentResourceRoot() {
var currentContainer = rootInstanceStackCursor.current;
return currentContainer ? getRootNode(currentContainer) : null;
return currentContainer ? getHoistableRoot(currentContainer) : null;
}
function getDocumentForPreloads() {
var root = getCurrentResourceRoot();
Expand Down Expand Up @@ -11726,7 +11726,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
break;
case 3:
propName = currentHoistableRoot;
currentHoistableRoot = root.containerInfo.getRootNode();
currentHoistableRoot = getHoistableRoot(root.containerInfo);
recursivelyTraverseMutationEffects(root, finishedWork);
currentHoistableRoot = propName;
commitReconciliationEffects(finishedWork);
Expand All @@ -11739,7 +11739,9 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
break;
case 4:
current = currentHoistableRoot;
currentHoistableRoot = finishedWork.stateNode.containerInfo.getRootNode();
currentHoistableRoot = getHoistableRoot(
finishedWork.stateNode.containerInfo
);
recursivelyTraverseMutationEffects(root, finishedWork);
commitReconciliationEffects(finishedWork);
currentHoistableRoot = current;
Expand Down Expand Up @@ -13349,7 +13351,7 @@ function shouldAttemptToSuspendUntilDataResolves() {
: !1;
}
function pushDispatcher(container) {
container = getRootNode(container);
container = getHoistableRoot(container);
lastCurrentDocument = container.ownerDocument || container;
previousDispatcher = Dispatcher.current;
Dispatcher.current = ReactDOMClientDispatcher;
Expand Down Expand Up @@ -15433,7 +15435,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1743 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-classic-2de85d7c7-20230210",
version: "18.3.0-www-classic-64acd3918-20230210",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2106 = {
Expand Down Expand Up @@ -15463,7 +15465,7 @@ var internals$jscomp$inline_2106 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-2de85d7c7-20230210"
reconcilerVersion: "18.3.0-next-64acd3918-20230210"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2107 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -15711,4 +15713,4 @@ exports.unstable_renderSubtreeIntoContainer = function (
);
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-next-2de85d7c7-20230210";
exports.version = "18.3.0-next-64acd3918-20230210";
18 changes: 10 additions & 8 deletions compiled/facebook-www/ReactDOM-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -4268,14 +4268,14 @@ var Dispatcher = Internals.Dispatcher,
previousDispatcher = null,
ReactDOMClientDispatcher = { preload: preload, preinit: preinit },
preloadPropsMap = new Map();
function getRootNode(container) {
function getHoistableRoot(container) {
return "function" === typeof container.getRootNode
? container.getRootNode()
: container.ownerDocument;
}
function getCurrentResourceRoot() {
var currentContainer = rootInstanceStackCursor.current;
return currentContainer ? getRootNode(currentContainer) : null;
return currentContainer ? getHoistableRoot(currentContainer) : null;
}
function getDocumentForPreloads() {
var root = getCurrentResourceRoot();
Expand Down Expand Up @@ -11502,7 +11502,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
break;
case 3:
propName = currentHoistableRoot;
currentHoistableRoot = root.containerInfo.getRootNode();
currentHoistableRoot = getHoistableRoot(root.containerInfo);
recursivelyTraverseMutationEffects(root, finishedWork);
currentHoistableRoot = propName;
commitReconciliationEffects(finishedWork);
Expand All @@ -11515,7 +11515,9 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
break;
case 4:
current = currentHoistableRoot;
currentHoistableRoot = finishedWork.stateNode.containerInfo.getRootNode();
currentHoistableRoot = getHoistableRoot(
finishedWork.stateNode.containerInfo
);
recursivelyTraverseMutationEffects(root, finishedWork);
commitReconciliationEffects(finishedWork);
currentHoistableRoot = current;
Expand Down Expand Up @@ -13125,7 +13127,7 @@ function shouldAttemptToSuspendUntilDataResolves() {
: !1;
}
function pushDispatcher(container) {
container = getRootNode(container);
container = getHoistableRoot(container);
lastCurrentDocument = container.ownerDocument || container;
previousDispatcher = Dispatcher.current;
Dispatcher.current = ReactDOMClientDispatcher;
Expand Down Expand Up @@ -14993,7 +14995,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1711 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-modern-2de85d7c7-20230210",
version: "18.3.0-www-modern-64acd3918-20230210",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2081 = {
Expand Down Expand Up @@ -15024,7 +15026,7 @@ var internals$jscomp$inline_2081 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-2de85d7c7-20230210"
reconcilerVersion: "18.3.0-next-64acd3918-20230210"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2082 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -15212,4 +15214,4 @@ exports.unstable_flushControlled = function (fn) {
}
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-next-2de85d7c7-20230210";
exports.version = "18.3.0-next-64acd3918-20230210";
Loading

0 comments on commit 427f9d9

Please sign in to comment.