mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix mutation sorting function
Summary: The sorting function currently forms a partial ordering, not a total ordering. This can cause problems with certain sequences of immediate or conflicting mutations, leading to UI corruption or crashes. Changelog: [Internal] Reviewed By: shergin Differential Revision: D24002668 fbshipit-source-id: edc9b4c1e3104897cb0c5fd6da563ec43d800494
This commit is contained in:
committed by
Facebook GitHub Bot
parent
521b16730d
commit
ca51dc6288
@@ -308,6 +308,14 @@ static inline bool shouldFirstComeBeforeSecondMutation(
|
||||
return true;
|
||||
}
|
||||
|
||||
// Update comes last, before deletes
|
||||
if (rhs.type == ShadowViewMutation::Type::Update) {
|
||||
return true;
|
||||
}
|
||||
if (lhs.type == ShadowViewMutation::Type::Update) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove comes before insert
|
||||
if (lhs.type == ShadowViewMutation::Type::Remove &&
|
||||
rhs.type == ShadowViewMutation::Type::Insert) {
|
||||
@@ -317,6 +325,16 @@ static inline bool shouldFirstComeBeforeSecondMutation(
|
||||
lhs.type == ShadowViewMutation::Type::Insert) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create comes before insert
|
||||
if (lhs.type == ShadowViewMutation::Type::Create &&
|
||||
rhs.type == ShadowViewMutation::Type::Insert) {
|
||||
return true;
|
||||
}
|
||||
if (rhs.type == ShadowViewMutation::Type::Create &&
|
||||
lhs.type == ShadowViewMutation::Type::Insert) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Make sure that removes on the same level are sorted - highest indices
|
||||
// must come first.
|
||||
|
||||
Reference in New Issue
Block a user