@@ -52,7 +52,8 @@ export function renderTransition(
5252 }
5353 }
5454 } else if ( animationName === 'none' ) {
55- sheet . addAnimationRaw ( 'old' , 'animation: none; opacity: 0; mix-blend-mode: normal;' ) ;
55+ sheet . addFallback ( 'old' , 'animation: none; mix-blend-mode: normal;' ) ;
56+ sheet . addModern ( 'old' , 'animation: none; opacity: 0; mix-blend-mode: normal;' ) ;
5657 sheet . addAnimationRaw ( 'new' , 'animation: none; mix-blend-mode: normal;' ) ;
5758 }
5859
@@ -88,11 +89,22 @@ class ViewTransitionStyleSheet {
8889 }
8990
9091 addAnimationRaw ( image : 'old' | 'new' | 'group' , animation : string ) {
91- const { scope, name } = this ;
92+ this . addModern ( image , animation ) ;
93+ this . addFallback ( image , animation ) ;
94+ }
95+
96+ addModern ( image : 'old' | 'new' | 'group' , animation : string ) {
97+ const { name } = this ;
9298 this . addRule ( 'modern' , `::view-transition-${ image } (${ name } ) { ${ animation } }` ) ;
99+ }
100+
101+ addFallback ( image : 'old' | 'new' | 'group' , animation : string ) {
102+ const { scope } = this ;
93103 this . addRule (
94104 'fallback' ,
95- `[data-astro-transition-fallback="${ image } "] [data-astro-transition-scope="${ scope } "] { ${ animation } }`
105+ // Two selectors here, the second in case there is an animation on the root.
106+ `[data-astro-transition-fallback="${ image } "] [data-astro-transition-scope="${ scope } "],
107+ [data-astro-transition-fallback="${ image } "][data-astro-transition-scope="${ scope } "] { ${ animation } }`
96108 ) ;
97109 }
98110
@@ -107,7 +119,8 @@ class ViewTransitionStyleSheet {
107119 this . addRule ( 'modern' , `${ prefix } ::view-transition-${ image } (${ name } ) { ${ animation } }` ) ;
108120 this . addRule (
109121 'fallback' ,
110- `${ prefix } [data-astro-transition-fallback="${ image } "] [data-astro-transition-scope="${ scope } "] { ${ animation } }`
122+ `${ prefix } [data-astro-transition-fallback="${ image } "] [data-astro-transition-scope="${ scope } "],
123+ ${ prefix } [data-astro-transition-fallback="${ image } "][data-astro-transition-scope="${ scope } "] { ${ animation } }`
111124 ) ;
112125 }
113126}
0 commit comments