mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-26 13:25:51 +08:00
Fabric: Using shallowSourceNode() inside ViewShadowNode::cloneAndReplaceChild()
Summary: We have to call shallowSourceNode() in all cases of cloning which were not caused by UIManager instructions, otherwise the diffing alogorith might produce incorrect mutation instructions. Reviewed By: mdvacca Differential Revision: D7503383 fbshipit-source-id: b33e5c39b7ba8cbd0f925fd29b3af379441a40a4
This commit is contained in:
committed by
Facebook Github Bot
parent
53837c4a4f
commit
47c0ab91a5
@@ -94,3 +94,27 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) {
|
||||
node5->clearSourceNode();
|
||||
ASSERT_EQ(node5->getSourceNode(), nullptr);
|
||||
}
|
||||
|
||||
TEST(ShadowNodeTest, handleSourceNode) {
|
||||
auto nodeFirstGeneration = std::make_shared<TestShadowNode>(9, 1, (void *)NULL);
|
||||
auto nodeSecondGeneration = std::make_shared<TestShadowNode>(nodeFirstGeneration);
|
||||
auto nodeThirdGeneration = std::make_shared<TestShadowNode>(nodeSecondGeneration);
|
||||
auto nodeForthGeneration = std::make_shared<TestShadowNode>(nodeThirdGeneration);
|
||||
|
||||
// Ensure established shource nodes structure.
|
||||
ASSERT_EQ(nodeForthGeneration->getSourceNode(), nodeThirdGeneration);
|
||||
ASSERT_EQ(nodeThirdGeneration->getSourceNode(), nodeSecondGeneration);
|
||||
ASSERT_EQ(nodeSecondGeneration->getSourceNode(), nodeFirstGeneration);
|
||||
|
||||
// Shallow source node for the forth generation node.
|
||||
nodeForthGeneration->shallowSourceNode();
|
||||
ASSERT_EQ(nodeForthGeneration->getSourceNode(), nodeSecondGeneration);
|
||||
|
||||
// Shallow it one more time.
|
||||
nodeForthGeneration->shallowSourceNode();
|
||||
ASSERT_EQ(nodeForthGeneration->getSourceNode(), nodeFirstGeneration);
|
||||
|
||||
// Ensure that 3th and 2nd were not affected.
|
||||
ASSERT_EQ(nodeThirdGeneration->getSourceNode(), nodeSecondGeneration);
|
||||
ASSERT_EQ(nodeSecondGeneration->getSourceNode(), nodeFirstGeneration);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user