|
1 | | -import { getTypeAttributes, polyfilledTypes, root } from './polyfilled-types.js'; |
| 1 | +import { polyfilledTypes, root } from './polyfilled-types.js'; |
2 | 2 | import { |
3 | 3 | createViewTransitionProxy, |
4 | 4 | SwitchableViewTransition, |
@@ -135,22 +135,37 @@ export function mayStartViewTransition( |
135 | 135 | if (!scopeData.currentViewTransition || collisionBehavior === 'skipOld') { |
136 | 136 | scopeData.keepLast = !!scopeData.currentViewTransition && !!scopeData.open; |
137 | 137 | scopeData.open = requestAnimationFrame(() => close(scopeData)); |
138 | | - scopeData.currentViewTransition = polyfilledTypes( |
139 | | - scope, |
140 | | - (scopeData.currentViewTransition = surrogate |
141 | | - ? createViewTransitionSurrogate(unchainUpdates) |
142 | | - : scope.startViewTransition!(unchainUpdates)), |
143 | | - useTypesPolyfill === 'always' || (useTypesPolyfill !== 'never' && nativeSupport === 'partial') |
144 | | - ); |
| 138 | + scopeData.currentViewTransition = surrogate |
| 139 | + ? createViewTransitionSurrogate(unchainUpdates) |
| 140 | + : scope.startViewTransition!(unchainUpdates); |
| 141 | + if ( |
| 142 | + useTypesPolyfill === 'always' || |
| 143 | + (useTypesPolyfill !== 'never' && nativeSupport === 'partial') |
| 144 | + ) |
| 145 | + scopeData.currentViewTransition = polyfilledTypes(scope, scopeData.currentViewTransition); |
| 146 | + |
| 147 | + const localTransition = scopeData.currentViewTransition; |
145 | 148 | if (catchErrors) { |
146 | 149 | const error = (e: any) => |
147 | 150 | (catchErrors as any) !== 'suppress' && (console.error(e), undefined); |
148 | 151 | scopeData.currentViewTransition.updateCallbackDone.catch(error); |
149 | 152 | scopeData.currentViewTransition.ready.catch(error); |
150 | 153 | } |
| 154 | + |
151 | 155 | scopeData.currentViewTransition.finished.finally(() => { |
152 | | - getTypeAttributes()?.forEach((t) => root(scope).classList.remove(t)); |
153 | | - scopeData.currentViewTransition = undefined; |
| 156 | + if (scopeData.currentViewTransition !== localTransition) { |
| 157 | + [...(localTransition.types ?? [])].forEach( |
| 158 | + (t) => |
| 159 | + scopeData.currentViewTransition?.types.has(t) || |
| 160 | + root(scope).classList.remove(`vtbag-vtt-${t}`) |
| 161 | + ); |
| 162 | + } else { |
| 163 | + [...(localTransition.types ?? [])].forEach((t) => |
| 164 | + root(scope).classList.remove(`vtbag-vtt-${t}`) |
| 165 | + ); |
| 166 | + root(scope).classList.remove('vtbag-vtt-0'); |
| 167 | + scopeData.currentViewTransition = undefined; |
| 168 | + } |
154 | 169 | scopeData.chained |
155 | 170 | .splice(0, scopeData.chained.length) |
156 | 171 | .forEach(({ update, extensions, proxy }) => { |
|
0 commit comments