mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 06:04:15 +00:00
Fabric: Fixed issue in the diffing algorithm
Summary: Previously we generated `removed` *or* `delete` instruction, but sometimes we have to generate both. So, basically we did it wrong. :( Reviewed By: mdvacca Differential Revision: D7503386 fbshipit-source-id: 8ee476abd29f088f31dc776f6e6a68d5293fbb35
This commit is contained in:
parent
db7f98b789
commit
c4bd7cef69
@ -38,7 +38,6 @@ void calculateMutationInstructions(
|
||||
TreeMutationInstructionList downwardInstructions = {};
|
||||
|
||||
// Stage 1: Collectings Updates
|
||||
|
||||
for (index = 0; index < oldChildNodes->size() && index < newChildNodes->size(); index++) {
|
||||
SharedShadowNode oldChildNode = oldChildNodes->at(index);
|
||||
SharedShadowNode newChildNode = newChildNodes->at(index);
|
||||
@ -76,7 +75,7 @@ void calculateMutationInstructions(
|
||||
insertInstructions.push_back(
|
||||
TreeMutationInstruction::Insert(
|
||||
parentNode,
|
||||
newChildNodes->at(index),
|
||||
newChildNode,
|
||||
index
|
||||
)
|
||||
);
|
||||
@ -99,20 +98,20 @@ void calculateMutationInstructions(
|
||||
for (index = lastIndexAfterFirstStage; index < oldChildNodes->size(); index++) {
|
||||
SharedShadowNode oldChildNode = oldChildNodes->at(index);
|
||||
|
||||
// Even if the old node was (re)inserted, we have to generate `remove`
|
||||
// instruction.
|
||||
removeInstructions.push_back(
|
||||
TreeMutationInstruction::Remove(
|
||||
parentNode,
|
||||
oldChildNode,
|
||||
index
|
||||
)
|
||||
);
|
||||
|
||||
auto numberOfRemovedTags = insertedTags.erase(oldChildNode->getTag());
|
||||
assert(numberOfRemovedTags == 0 || numberOfRemovedTags == 1);
|
||||
|
||||
if (numberOfRemovedTags != 0) {
|
||||
// The old node *was* (re)inserted,
|
||||
// so we have to generate `remove` instruction.
|
||||
removeInstructions.push_back(
|
||||
TreeMutationInstruction::Remove(
|
||||
parentNode,
|
||||
oldChildNode,
|
||||
index
|
||||
)
|
||||
);
|
||||
} else {
|
||||
if (numberOfRemovedTags == 0) {
|
||||
// The old node was *not* (re)inserted,
|
||||
// so we have to generate `delete` instruction and apply the algorithm
|
||||
// recursively.
|
||||
|
Loading…
x
Reference in New Issue
Block a user