From 851b570f4a975315bbe18607f52868c2c63f5d8a Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Mon, 7 Dec 2020 15:30:31 -0600 Subject: [PATCH] Don't clear other flags when adding Deletion Same as #20398 but for Deletions. There's no new regression test, but in the effects refactor, existing tests will fail without this. --- packages/react-reconciler/src/ReactChildFiber.new.js | 9 +++++++-- .../react-reconciler/src/ReactFiberBeginWork.new.js | 5 +++-- .../src/ReactFiberHydrationContext.new.js | 10 ++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/react-reconciler/src/ReactChildFiber.new.js b/packages/react-reconciler/src/ReactChildFiber.new.js index d8894768c6d91..7163df34d8568 100644 --- a/packages/react-reconciler/src/ReactChildFiber.new.js +++ b/packages/react-reconciler/src/ReactChildFiber.new.js @@ -13,7 +13,12 @@ import type {Fiber} from './ReactInternalTypes'; import type {Lanes} from './ReactFiberLane.new'; import getComponentName from 'shared/getComponentName'; -import {Deletion, ChildDeletion, Placement} from './ReactFiberFlags'; +import { + Deletion, + ChildDeletion, + Placement, + StaticMask, +} from './ReactFiberFlags'; import { getIteratorFn, REACT_ELEMENT_TYPE, @@ -275,7 +280,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; } childToDelete.nextEffect = null; - childToDelete.flags = Deletion; + childToDelete.flags = (childToDelete.flags & StaticMask) | Deletion; let deletions = returnFiber.deletions; if (deletions === null) { diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index 3ae2541bf061a..056d9c8b1ca7f 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -2007,7 +2007,8 @@ function updateSuspensePrimaryChildren( if (currentFallbackChildFragment !== null) { // Delete the fallback child fragment currentFallbackChildFragment.nextEffect = null; - currentFallbackChildFragment.flags = Deletion; + currentFallbackChildFragment.flags = + (currentFallbackChildFragment.flags & StaticMask) | Deletion; workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; let deletions = workInProgress.deletions; if (deletions === null) { @@ -2998,7 +2999,7 @@ function remountFiber( returnFiber.firstEffect = returnFiber.lastEffect = current; } current.nextEffect = null; - current.flags = Deletion; + current.flags = (current.flags & StaticMask) | Deletion; let deletions = returnFiber.deletions; if (deletions === null) { diff --git a/packages/react-reconciler/src/ReactFiberHydrationContext.new.js b/packages/react-reconciler/src/ReactFiberHydrationContext.new.js index 85ddcca5f08eb..37be28be6628c 100644 --- a/packages/react-reconciler/src/ReactFiberHydrationContext.new.js +++ b/packages/react-reconciler/src/ReactFiberHydrationContext.new.js @@ -24,7 +24,13 @@ import { HostRoot, SuspenseComponent, } from './ReactWorkTags'; -import {Deletion, ChildDeletion, Placement, Hydrating} from './ReactFiberFlags'; +import { + Deletion, + ChildDeletion, + Placement, + Hydrating, + StaticMask, +} from './ReactFiberFlags'; import invariant from 'shared/invariant'; import { @@ -124,7 +130,7 @@ function deleteHydratableInstance( const childToDelete = createFiberFromHostInstanceForDeletion(); childToDelete.stateNode = instance; childToDelete.return = returnFiber; - childToDelete.flags = Deletion; + childToDelete.flags = (childToDelete.flags & StaticMask) | Deletion; // This might seem like it belongs on progressedFirstDeletion. However, // these children are not part of the reconciliation list of children.