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 88d6d34 commit 09440f4
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 33 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
3 changes: 1 addition & 2 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberCompleteWork.old.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ import {
HostEffectMask,
Hydrating,
HydratingAndUpdate,
ClearContainer,
} from './ReactSideEffectTags';
import {
NoWork,
Expand Down Expand Up @@ -2064,7 +2063,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 09440f4

Please sign in to comment.