mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix: patch public renderer implementations to include isChildPublicInstance (#42249)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42249 Changelog: [Internal] Manually patching public React renderers artifacts to include `isChildPublicInstance` method, which was added in https://github.com/facebook/react/pull/27783. To identifly the required changes in code I've ran a diff for 2 commits: 1. The one with the changes 2. Its parent FB implementation were synced in D51816108. Reviewed By: sammy-SC Differential Revision: D52697885 fbshipit-source-id: c62af6e89e8da3ee6f6c7264bacf6e96030e9db8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c393f7ae92
commit
c989f63fdb
+56
-1
@@ -3388,6 +3388,20 @@ function findCurrentHostFiberImpl(node) {
|
||||
|
||||
return null;
|
||||
}
|
||||
function doesFiberContain(parentFiber, childFiber) {
|
||||
var node = childFiber;
|
||||
var parentFiberAlternate = parentFiber.alternate;
|
||||
|
||||
while (node !== null) {
|
||||
if (node === parentFiber || node === parentFiberAlternate) {
|
||||
return true;
|
||||
}
|
||||
|
||||
node = node.return;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* In the future, we should cleanup callbacks by cancelling them instead of
|
||||
@@ -24331,6 +24345,46 @@ function sendAccessibilityEvent(handle, eventType) {
|
||||
}
|
||||
}
|
||||
|
||||
function isChildPublicInstance(parentInstance, childInstance) {
|
||||
{
|
||||
// Paper
|
||||
if (
|
||||
// $FlowExpectedError[incompatible-type]
|
||||
// $FlowExpectedError[prop-missing] Don't check via `instanceof ReactNativeFiberHostComponent`, so it won't be leaked to Fabric.
|
||||
parentInstance._internalFiberInstanceHandleDEV && // $FlowExpectedError[incompatible-type]
|
||||
// $FlowExpectedError[prop-missing] Don't check via `instanceof ReactNativeFiberHostComponent`, so it won't be leaked to Fabric.
|
||||
childInstance._internalFiberInstanceHandleDEV
|
||||
) {
|
||||
return doesFiberContain(
|
||||
// $FlowExpectedError[incompatible-call]
|
||||
parentInstance._internalFiberInstanceHandleDEV, // $FlowExpectedError[incompatible-call]
|
||||
childInstance._internalFiberInstanceHandleDEV
|
||||
);
|
||||
}
|
||||
|
||||
var parentInternalInstanceHandle = // $FlowExpectedError[incompatible-call] Type for parentInstance should have been PublicInstance from ReactFiberConfigFabric.
|
||||
ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance(
|
||||
parentInstance
|
||||
);
|
||||
var childInternalInstanceHandle = // $FlowExpectedError[incompatible-call] Type for childInstance should have been PublicInstance from ReactFiberConfigFabric.
|
||||
ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance(
|
||||
childInstance
|
||||
); // Fabric
|
||||
|
||||
if (
|
||||
parentInternalInstanceHandle != null &&
|
||||
childInternalInstanceHandle != null
|
||||
) {
|
||||
return doesFiberContain(
|
||||
parentInternalInstanceHandle,
|
||||
childInternalInstanceHandle
|
||||
);
|
||||
} // Means that one instance is from Fabric and other is from Paper.
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onRecoverableError(error$1) {
|
||||
// TODO: Expose onRecoverableError option to userspace
|
||||
// eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args
|
||||
@@ -24401,6 +24455,7 @@ exports.createPortal = createPortal$1;
|
||||
exports.dispatchCommand = dispatchCommand;
|
||||
exports.findHostInstance_DEPRECATED = findHostInstance_DEPRECATED;
|
||||
exports.findNodeHandle = findNodeHandle;
|
||||
exports.isChildPublicInstance = isChildPublicInstance;
|
||||
exports.render = render;
|
||||
exports.sendAccessibilityEvent = sendAccessibilityEvent;
|
||||
exports.stopSurface = stopSurface;
|
||||
@@ -24414,6 +24469,6 @@ if (
|
||||
) {
|
||||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
||||
}
|
||||
|
||||
|
||||
})();
|
||||
}
|
||||
|
||||
@@ -8386,6 +8386,9 @@ exports.findHostInstance_DEPRECATED = function(componentOrHandle) {
|
||||
};
|
||||
exports.findNodeHandle = findNodeHandle;
|
||||
exports.getInspectorDataForInstance = void 0;
|
||||
exports.isChildPublicInstance = function () {
|
||||
throw Error("isChildPublicInstance() is not available in production.");
|
||||
};
|
||||
exports.render = function(element, containerTag, callback, concurrentRoot) {
|
||||
var root = roots.get(containerTag);
|
||||
root ||
|
||||
|
||||
+3
-1
@@ -8863,6 +8863,9 @@ exports.findHostInstance_DEPRECATED = function(componentOrHandle) {
|
||||
};
|
||||
exports.findNodeHandle = findNodeHandle;
|
||||
exports.getInspectorDataForInstance = void 0;
|
||||
exports.isChildPublicInstance = function () {
|
||||
throw Error("isChildPublicInstance() is not available in production.");
|
||||
};
|
||||
exports.render = function(element, containerTag, callback, concurrentRoot) {
|
||||
var root = roots.get(containerTag);
|
||||
root ||
|
||||
@@ -8931,4 +8934,3 @@ if (
|
||||
) {
|
||||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
||||
}
|
||||
|
||||
|
||||
+56
-1
@@ -3676,6 +3676,20 @@ function findCurrentHostFiberImpl(node) {
|
||||
|
||||
return null;
|
||||
}
|
||||
function doesFiberContain(parentFiber, childFiber) {
|
||||
var node = childFiber;
|
||||
var parentFiberAlternate = parentFiber.alternate;
|
||||
|
||||
while (node !== null) {
|
||||
if (node === parentFiber || node === parentFiberAlternate) {
|
||||
return true;
|
||||
}
|
||||
|
||||
node = node.return;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Modules provided by RN:
|
||||
var emptyObject = {};
|
||||
@@ -24651,6 +24665,46 @@ function sendAccessibilityEvent(handle, eventType) {
|
||||
}
|
||||
}
|
||||
|
||||
function isChildPublicInstance(parentInstance, childInstance) {
|
||||
{
|
||||
// Paper
|
||||
if (
|
||||
// $FlowExpectedError[incompatible-type]
|
||||
// $FlowExpectedError[prop-missing] Don't check via `instanceof ReactNativeFiberHostComponent`, so it won't be leaked to Fabric.
|
||||
parentInstance._internalFiberInstanceHandleDEV && // $FlowExpectedError[incompatible-type]
|
||||
// $FlowExpectedError[prop-missing] Don't check via `instanceof ReactNativeFiberHostComponent`, so it won't be leaked to Fabric.
|
||||
childInstance._internalFiberInstanceHandleDEV
|
||||
) {
|
||||
return doesFiberContain(
|
||||
// $FlowExpectedError[incompatible-call]
|
||||
parentInstance._internalFiberInstanceHandleDEV, // $FlowExpectedError[incompatible-call]
|
||||
childInstance._internalFiberInstanceHandleDEV
|
||||
);
|
||||
}
|
||||
|
||||
var parentInternalInstanceHandle = // $FlowExpectedError[incompatible-call] Type for parentInstance should have been PublicInstance from ReactFiberConfigFabric.
|
||||
ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance(
|
||||
parentInstance
|
||||
);
|
||||
var childInternalInstanceHandle = // $FlowExpectedError[incompatible-call] Type for childInstance should have been PublicInstance from ReactFiberConfigFabric.
|
||||
ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance(
|
||||
childInstance
|
||||
); // Fabric
|
||||
|
||||
if (
|
||||
parentInternalInstanceHandle != null &&
|
||||
childInternalInstanceHandle != null
|
||||
) {
|
||||
return doesFiberContain(
|
||||
parentInternalInstanceHandle,
|
||||
childInternalInstanceHandle
|
||||
);
|
||||
} // Means that one instance is from Fabric and other is from Paper.
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onRecoverableError(error$1) {
|
||||
// TODO: Expose onRecoverableError option to userspace
|
||||
// eslint-disable-next-line react-internal/no-production-logging, react-internal/warning-args
|
||||
@@ -24738,6 +24792,7 @@ exports.createPortal = createPortal$1;
|
||||
exports.dispatchCommand = dispatchCommand;
|
||||
exports.findHostInstance_DEPRECATED = findHostInstance_DEPRECATED;
|
||||
exports.findNodeHandle = findNodeHandle;
|
||||
exports.isChildPublicInstance = isChildPublicInstance;
|
||||
exports.render = render;
|
||||
exports.sendAccessibilityEvent = sendAccessibilityEvent;
|
||||
exports.unmountComponentAtNode = unmountComponentAtNode;
|
||||
@@ -24752,6 +24807,6 @@ if (
|
||||
) {
|
||||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
||||
}
|
||||
|
||||
|
||||
})();
|
||||
}
|
||||
|
||||
+3
@@ -8564,6 +8564,9 @@ exports.findHostInstance_DEPRECATED = function(componentOrHandle) {
|
||||
};
|
||||
exports.findNodeHandle = findNodeHandle;
|
||||
exports.getInspectorDataForInstance = void 0;
|
||||
exports.isChildPublicInstance = function () {
|
||||
throw Error("isChildPublicInstance() is not available in production.");
|
||||
};
|
||||
exports.render = function(element, containerTag, callback) {
|
||||
var root = roots.get(containerTag);
|
||||
if (!root) {
|
||||
|
||||
+3
-1
@@ -9040,6 +9040,9 @@ exports.findHostInstance_DEPRECATED = function(componentOrHandle) {
|
||||
};
|
||||
exports.findNodeHandle = findNodeHandle;
|
||||
exports.getInspectorDataForInstance = void 0;
|
||||
exports.isChildPublicInstance = function () {
|
||||
throw Error("isChildPublicInstance() is not available in production.");
|
||||
};
|
||||
exports.render = function(element, containerTag, callback) {
|
||||
var root = roots.get(containerTag);
|
||||
if (!root) {
|
||||
@@ -9102,4 +9105,3 @@ if (
|
||||
) {
|
||||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user