Skip to content

Commit 08064ea

Browse files
authored
[Fizz] Make ViewTransition enter/exit/share null the same as none (facebook#33331)
I believe that these mean the same thing. We don't have to emit the attribute if it's `none` for these cases because if there is no matching scenario we won't apply the animation in this case. The only case where we have to emit `none` in the attribute is for `vt-update` because those can block updates from propagating upwards.
1 parent 99781d6 commit 08064ea

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,9 @@ const SUBTREE_SCOPE = ~(ENTER_SCOPE | EXIT_SCOPE);
759759

760760
type ViewTransitionContext = {
761761
update: 'none' | 'auto' | string,
762-
// null here means that this case can never trigger. Not "auto" like it does in props.
763-
enter: null | 'none' | 'auto' | string,
764-
exit: null | 'none' | 'auto' | string,
765-
share: null | 'none' | 'auto' | string,
762+
enter: 'none' | 'auto' | string,
763+
exit: 'none' | 'auto' | string,
764+
share: 'none' | 'auto' | string,
766765
name: 'auto' | string,
767766
autoName: string, // a name that can be used if an explicit one is not defined.
768767
nameIdx: number, // keeps track of how many duplicates of this name we've emitted.
@@ -917,8 +916,8 @@ function getSuspenseViewTransition(
917916
// we would've used (the parent ViewTransition name or auto-assign one).
918917
const viewTransition: ViewTransitionContext = {
919918
update: parentViewTransition.update, // For deep updates.
920-
enter: null,
921-
exit: null,
919+
enter: 'none',
920+
exit: 'none',
922921
share: parentViewTransition.update, // For exit or enter of reveals.
923922
name: parentViewTransition.autoName,
924923
autoName: parentViewTransition.autoName,
@@ -989,13 +988,8 @@ export function getViewTransitionFormatContext(
989988
share = parentViewTransition.share;
990989
} else {
991990
name = 'auto';
992-
share = null; // share is only relevant if there's an explicit name
991+
share = 'none'; // share is only relevant if there's an explicit name
993992
}
994-
} else if (share === 'none') {
995-
// I believe if share is disabled, it means the same thing as if it doesn't
996-
// exit because enter/exit will take precedence and if it's deeply nested
997-
// it just animates along whatever the parent does when disabled.
998-
share = null;
999993
} else {
1000994
if (share == null) {
1001995
share = 'auto';
@@ -1008,12 +1002,12 @@ export function getViewTransitionFormatContext(
10081002
}
10091003
}
10101004
if (!(parentContext.tagScope & EXIT_SCOPE)) {
1011-
exit = null; // exit is only relevant for the first ViewTransition inside fallback
1005+
exit = 'none'; // exit is only relevant for the first ViewTransition inside fallback
10121006
} else {
10131007
resumableState.instructions |= NeedUpgradeToViewTransitions;
10141008
}
10151009
if (!(parentContext.tagScope & ENTER_SCOPE)) {
1016-
enter = null; // enter is only relevant for the first ViewTransition inside content
1010+
enter = 'none'; // enter is only relevant for the first ViewTransition inside content
10171011
} else {
10181012
resumableState.instructions |= NeedUpgradeToViewTransitions;
10191013
}
@@ -1125,13 +1119,13 @@ function pushViewTransitionAttributes(
11251119
viewTransition.nameIdx++;
11261120
}
11271121
pushStringAttribute(target, 'vt-update', viewTransition.update);
1128-
if (viewTransition.enter !== null) {
1122+
if (viewTransition.enter !== 'none') {
11291123
pushStringAttribute(target, 'vt-enter', viewTransition.enter);
11301124
}
1131-
if (viewTransition.exit !== null) {
1125+
if (viewTransition.exit !== 'none') {
11321126
pushStringAttribute(target, 'vt-exit', viewTransition.exit);
11331127
}
1134-
if (viewTransition.share !== null) {
1128+
if (viewTransition.share !== 'none') {
11351129
pushStringAttribute(target, 'vt-share', viewTransition.share);
11361130
}
11371131
}

0 commit comments

Comments
 (0)