Skip to content

Commit

Permalink
Replaced ClearContainer tag with Snapshot for clearing HostRoots
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Apr 25, 2020
1 parent 286f27b commit 752d60c
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 33 deletions.
Expand Up @@ -74,7 +74,7 @@ describe('when Trusted Types are available in global object', () => {
container,
);
expect(container.innerHTML).toBe('<div><b>Hi</b></div>');
// Second call to innerHTML is the ClearContainer check.
// Second call to innerHTML is the clearContainer check.
expect(innerHTMLCalls.length).toBe(2);
// Ensure it didn't get stringified when passed to a DOM sink:
expect(innerHTMLCalls[0]).toBe(ttObject1);
Expand Down
3 changes: 1 addition & 2 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Expand Up @@ -70,7 +70,6 @@ import {
Snapshot,
Update,
Passive,
ClearContainer,
} from './ReactSideEffectTags';
import getComponentName from 'shared/getComponentName';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -299,7 +298,7 @@ function commitBeforeMutationLifeCycles(
}
case HostRoot: {
if (supportsMutation) {
if (finishedWork.effectTag & ClearContainer) {
if (finishedWork.effectTag & Snapshot) {
const root = finishedWork.stateNode;
clearContainer(root.containerInfo);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Expand Up @@ -68,7 +68,6 @@ import {
Snapshot,
Update,
Passive,
ClearContainer,
} from './ReactSideEffectTags';
import getComponentName from 'shared/getComponentName';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -297,7 +296,7 @@ function commitBeforeMutationLifeCycles(
}
case HostRoot: {
if (supportsMutation) {
if (finishedWork.effectTag & ClearContainer) {
if (finishedWork.effectTag & Snapshot) {
const root = finishedWork.stateNode;
clearContainer(root.containerInfo);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberCompleteWork.new.js
Expand Up @@ -63,7 +63,7 @@ import {
Update,
NoEffect,
DidCapture,
ClearContainer,
Snapshot,
} from './ReactSideEffectTags';
import invariant from 'shared/invariant';

Expand Down Expand Up @@ -690,7 +690,7 @@ function completeWork(
// This handles the case of React rendering into a container with previous children.
// It's also safe to do for updates too, because current.child would only be null
// if the previous render was null (so the the container would already be empty).
workInProgress.effectTag |= ClearContainer;
workInProgress.effectTag |= Snapshot;
}
}
updateHostContainer(workInProgress);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberCompleteWork.old.js
Expand Up @@ -61,7 +61,7 @@ import {
NoEffect,
DidCapture,
Deletion,
ClearContainer,
Snapshot,
} from './ReactSideEffectTags';
import invariant from 'shared/invariant';

Expand Down Expand Up @@ -684,7 +684,7 @@ function completeWork(
// This handles the case of React rendering into a container with previous children.
// It's also safe to do for updates too, because current.child would only be null
// if the previous render was null (so the the container would already be empty).
workInProgress.effectTag |= ClearContainer;
workInProgress.effectTag |= Snapshot;
}
}
updateHostContainer(workInProgress);
Expand Down
3 changes: 1 addition & 2 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Expand Up @@ -111,7 +111,6 @@ import {
HostEffectMask,
Hydrating,
HydratingAndUpdate,
ClearContainer,
} from './ReactSideEffectTags';
import {
NoWork,
Expand Down Expand Up @@ -2241,7 +2240,7 @@ function commitBeforeMutationEffects() {
beforeActiveInstanceBlur();
}
const effectTag = nextEffect.effectTag;
if ((effectTag & (Snapshot | ClearContainer)) !== NoEffect) {
if ((effectTag & Snapshot) !== NoEffect) {
setCurrentDebugFiberInDEV(nextEffect);

const current = nextEffect.alternate;
Expand Down
3 changes: 1 addition & 2 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Expand Up @@ -123,7 +123,6 @@ import {
HostEffectMask,
Hydrating,
HydratingAndUpdate,
ClearContainer,
} from './ReactSideEffectTags';
import {
NoWork,
Expand Down Expand Up @@ -2168,7 +2167,7 @@ function commitBeforeMutationEffects() {
beforeActiveInstanceBlur();
}
const effectTag = nextEffect.effectTag;
if ((effectTag & (Snapshot | ClearContainer)) !== NoEffect) {
if ((effectTag & Snapshot) !== NoEffect) {
setCurrentDebugFiberInDEV(nextEffect);

const current = nextEffect.alternate;
Expand Down
39 changes: 19 additions & 20 deletions packages/react-reconciler/src/ReactSideEffectTags.js
Expand Up @@ -10,30 +10,29 @@
export type SideEffectTag = number;

// Don't change these two values. They're used by React Dev Tools.
export const NoEffect = /* */ 0b000000000000000;
export const PerformedWork = /* */ 0b000000000000001;
export const NoEffect = /* */ 0b00000000000000;
export const PerformedWork = /* */ 0b00000000000001;

// You can change the rest (and add more).
export const Placement = /* */ 0b000000000000010;
export const Update = /* */ 0b000000000000100;
export const PlacementAndUpdate = /* */ 0b000000000000110;
export const Deletion = /* */ 0b000000000001000;
export const ContentReset = /* */ 0b000000000010000;
export const Callback = /* */ 0b000000000100000;
export const DidCapture = /* */ 0b000000001000000;
export const Ref = /* */ 0b000000010000000;
export const Snapshot = /* */ 0b000000100000000;
export const Passive = /* */ 0b000001000000000;
export const PassiveUnmountPendingDev = /* */ 0b010000000000000;
export const Hydrating = /* */ 0b000010000000000;
export const HydratingAndUpdate = /* */ 0b000010000000100;
export const ClearContainer = /* */ 0b100000000000000;
export const Placement = /* */ 0b00000000000010;
export const Update = /* */ 0b00000000000100;
export const PlacementAndUpdate = /* */ 0b00000000000110;
export const Deletion = /* */ 0b00000000001000;
export const ContentReset = /* */ 0b00000000010000;
export const Callback = /* */ 0b00000000100000;
export const DidCapture = /* */ 0b00000001000000;
export const Ref = /* */ 0b00000010000000;
export const Snapshot = /* */ 0b00000100000000;
export const Passive = /* */ 0b00001000000000;
export const PassiveUnmountPendingDev = /* */ 0b10000000000000;
export const Hydrating = /* */ 0b00010000000000;
export const HydratingAndUpdate = /* */ 0b00010000000100;

// Passive & Update & Callback & Ref & Snapshot
export const LifecycleEffectMask = /* */ 0b000001110100100;
export const LifecycleEffectMask = /* */ 0b00001110100100;

// Union of all host effects
export const HostEffectMask = /* */ 0b000011111111111;
export const HostEffectMask = /* */ 0b00011111111111;

export const Incomplete = /* */ 0b000100000000000;
export const ShouldCapture = /* */ 0b001000000000000;
export const Incomplete = /* */ 0b00100000000000;
export const ShouldCapture = /* */ 0b01000000000000;

0 comments on commit 752d60c

Please sign in to comment.