Skip to content

Commit

Permalink
[Fiber] getHoistableRoot() should account for Document containers (#…
Browse files Browse the repository at this point in the history
…32321)

While modern DOM implementations all support getRootNode if you are
running React in a runtime which does not the fallback logic which uses
`.ownerDocument` works everywhere except when the container is a
Document itself. This change corrects this by returning the container
intsance if it is a Document type.

DiffTrain build for [b48e739](b48e739)
  • Loading branch information
gnoff committed Feb 6, 2025
1 parent 9f6cb64 commit 2ca4fae
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 92 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.1.0-native-fb-ff628334-20250205
19.1.0-native-fb-b48e7399-20250206
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<cbd289e323f7a8415dbd55fd449a4cb3>>
* @generated SignedSource<<62f7075a95158f271aa4bcfd217c458e>>
*/

"use strict";
Expand Down Expand Up @@ -428,5 +428,5 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-ff628334-20250205";
exports.version = "19.1.0-native-fb-b48e7399-20250206";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<76039a6de37b6ad225a095a4d8a23b62>>
* @generated SignedSource<<f9d4e77e757ae66cbcb1d7414f754042>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-ff628334-20250205";
exports.version = "19.1.0-native-fb-b48e7399-20250206";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<76039a6de37b6ad225a095a4d8a23b62>>
* @generated SignedSource<<f9d4e77e757ae66cbcb1d7414f754042>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-ff628334-20250205";
exports.version = "19.1.0-native-fb-b48e7399-20250206";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<53f2738f295e889392402f62bb65d4fb>>
* @generated SignedSource<<0210959d65b7dd74eefb8e2616b5eecc>>
*/

/*
Expand Down Expand Up @@ -20709,7 +20709,9 @@ __DEV__ &&
function getHoistableRoot(container) {
return "function" === typeof container.getRootNode
? container.getRootNode()
: container.ownerDocument;
: 9 === container.nodeType
? container
: container.ownerDocument;
}
function preconnectAs(rel, href, crossOrigin) {
var ownerDocument = globalDocument;
Expand Down Expand Up @@ -26003,11 +26005,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.1.0-native-fb-ff628334-20250205" !== isomorphicReactPackageVersion)
if ("19.1.0-native-fb-b48e7399-20250206" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.1.0-native-fb-ff628334-20250205\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.1.0-native-fb-b48e7399-20250206\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -26044,10 +26046,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.1.0-native-fb-ff628334-20250205",
version: "19.1.0-native-fb-b48e7399-20250206",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-ff628334-20250205"
reconcilerVersion: "19.1.0-native-fb-b48e7399-20250206"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -26191,5 +26193,5 @@ __DEV__ &&
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.1.0-native-fb-ff628334-20250205";
exports.version = "19.1.0-native-fb-b48e7399-20250206";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9aa58e05a9a44a6e0c497301edb51fd9>>
* @generated SignedSource<<5f0cfb6e40046900dc3eced0829c002e>>
*/

/*
Expand Down Expand Up @@ -14499,7 +14499,9 @@ var preloadPropsMap = new Map(),
function getHoistableRoot(container) {
return "function" === typeof container.getRootNode
? container.getRootNode()
: container.ownerDocument;
: 9 === container.nodeType
? container
: container.ownerDocument;
}
var previousDispatcher = ReactDOMSharedInternals.d;
ReactDOMSharedInternals.d = {
Expand Down Expand Up @@ -16016,14 +16018,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1802 = React.version;
if (
"19.1.0-native-fb-ff628334-20250205" !==
"19.1.0-native-fb-b48e7399-20250206" !==
isomorphicReactPackageVersion$jscomp$inline_1802
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1802,
"19.1.0-native-fb-ff628334-20250205"
"19.1.0-native-fb-b48e7399-20250206"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16045,10 +16047,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2262 = {
bundleType: 0,
version: "19.1.0-native-fb-ff628334-20250205",
version: "19.1.0-native-fb-b48e7399-20250206",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-ff628334-20250205"
reconcilerVersion: "19.1.0-native-fb-b48e7399-20250206"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2263 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -16152,4 +16154,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.1.0-native-fb-ff628334-20250205";
exports.version = "19.1.0-native-fb-b48e7399-20250206";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<59e5ad0acce0802c9e75da9cd92ab1f3>>
* @generated SignedSource<<7b93297b0f45500f277a91a830b00250>>
*/

/*
Expand Down Expand Up @@ -15140,7 +15140,9 @@ var preloadPropsMap = new Map(),
function getHoistableRoot(container) {
return "function" === typeof container.getRootNode
? container.getRootNode()
: container.ownerDocument;
: 9 === container.nodeType
? container
: container.ownerDocument;
}
var previousDispatcher = ReactDOMSharedInternals.d;
ReactDOMSharedInternals.d = {
Expand Down Expand Up @@ -16665,14 +16667,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1897 = React.version;
if (
"19.1.0-native-fb-ff628334-20250205" !==
"19.1.0-native-fb-b48e7399-20250206" !==
isomorphicReactPackageVersion$jscomp$inline_1897
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1897,
"19.1.0-native-fb-ff628334-20250205"
"19.1.0-native-fb-b48e7399-20250206"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16694,10 +16696,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_1904 = {
bundleType: 0,
version: "19.1.0-native-fb-ff628334-20250205",
version: "19.1.0-native-fb-b48e7399-20250206",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-ff628334-20250205",
reconcilerVersion: "19.1.0-native-fb-b48e7399-20250206",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$294 = 0;
Expand Down Expand Up @@ -16816,4 +16818,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.1.0-native-fb-ff628334-20250205";
exports.version = "19.1.0-native-fb-b48e7399-20250206";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<5164734a56abefd6fcd812a8342c804d>>
* @generated SignedSource<<2513cf260af6ca46f66ecb657d7b2901>>
*/

/*
Expand Down Expand Up @@ -20721,7 +20721,9 @@ __DEV__ &&
function getHoistableRoot(container) {
return "function" === typeof container.getRootNode
? container.getRootNode()
: container.ownerDocument;
: 9 === container.nodeType
? container
: container.ownerDocument;
}
function preconnectAs(rel, href, crossOrigin) {
var ownerDocument = globalDocument;
Expand Down Expand Up @@ -26064,11 +26066,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.1.0-native-fb-ff628334-20250205" !== isomorphicReactPackageVersion)
if ("19.1.0-native-fb-b48e7399-20250206" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.1.0-native-fb-ff628334-20250205\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.1.0-native-fb-b48e7399-20250206\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -26105,10 +26107,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.1.0-native-fb-ff628334-20250205",
version: "19.1.0-native-fb-b48e7399-20250206",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-ff628334-20250205"
reconcilerVersion: "19.1.0-native-fb-b48e7399-20250206"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -26568,7 +26570,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-ff628334-20250205";
exports.version = "19.1.0-native-fb-b48e7399-20250206";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<4ee844129940b1cdacc992f796eb5e29>>
* @generated SignedSource<<2a0a722d7897c658cc3a6e00d5471de5>>
*/

/*
Expand Down Expand Up @@ -14499,7 +14499,9 @@ var preloadPropsMap = new Map(),
function getHoistableRoot(container) {
return "function" === typeof container.getRootNode
? container.getRootNode()
: container.ownerDocument;
: 9 === container.nodeType
? container
: container.ownerDocument;
}
var previousDispatcher = ReactDOMSharedInternals.d;
ReactDOMSharedInternals.d = {
Expand Down Expand Up @@ -16027,14 +16029,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1803 = React.version;
if (
"19.1.0-native-fb-ff628334-20250205" !==
"19.1.0-native-fb-b48e7399-20250206" !==
isomorphicReactPackageVersion$jscomp$inline_1803
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1803,
"19.1.0-native-fb-ff628334-20250205"
"19.1.0-native-fb-b48e7399-20250206"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16056,10 +16058,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2265 = {
bundleType: 0,
version: "19.1.0-native-fb-ff628334-20250205",
version: "19.1.0-native-fb-b48e7399-20250206",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-ff628334-20250205"
reconcilerVersion: "19.1.0-native-fb-b48e7399-20250206"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2266 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -16317,4 +16319,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-ff628334-20250205";
exports.version = "19.1.0-native-fb-b48e7399-20250206";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<f1827a84106b8091079e4998b550636c>>
* @generated SignedSource<<7a906fbdbe281c084654742edb2693dc>>
*/

/*
Expand Down Expand Up @@ -15144,7 +15144,9 @@ var preloadPropsMap = new Map(),
function getHoistableRoot(container) {
return "function" === typeof container.getRootNode
? container.getRootNode()
: container.ownerDocument;
: 9 === container.nodeType
? container
: container.ownerDocument;
}
var previousDispatcher = ReactDOMSharedInternals.d;
ReactDOMSharedInternals.d = {
Expand Down Expand Up @@ -16680,14 +16682,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1898 = React.version;
if (
"19.1.0-native-fb-ff628334-20250205" !==
"19.1.0-native-fb-b48e7399-20250206" !==
isomorphicReactPackageVersion$jscomp$inline_1898
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1898,
"19.1.0-native-fb-ff628334-20250205"
"19.1.0-native-fb-b48e7399-20250206"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16709,10 +16711,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_1905 = {
bundleType: 0,
version: "19.1.0-native-fb-ff628334-20250205",
version: "19.1.0-native-fb-b48e7399-20250206",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-native-fb-ff628334-20250205",
reconcilerVersion: "19.1.0-native-fb-b48e7399-20250206",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$294 = 0;
Expand Down Expand Up @@ -16985,7 +16987,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.1.0-native-fb-ff628334-20250205";
exports.version = "19.1.0-native-fb-b48e7399-20250206";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Loading

0 comments on commit 2ca4fae

Please sign in to comment.