Skip to content

Commit

Permalink
fix(router): use DOCUMENT token instead of document directly in view …
Browse files Browse the repository at this point in the history
…transitions (#51814)

document is not available in SSR so using it directly will lead to an error.

PR Close #51814
  • Loading branch information
atscott authored and pkozlowski-opensource committed Sep 19, 2023
1 parent d538908 commit c03baed
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/router/src/utils/view_transition.ts
Expand Up @@ -8,6 +8,7 @@

/// <reference types="@types/dom-view-transitions" />

import {DOCUMENT} from '@angular/common';
import {afterNextRender, InjectionToken, Injector, NgZone} from '@angular/core';

export const CREATE_VIEW_TRANSITION =
Expand All @@ -22,6 +23,7 @@ export const CREATE_VIEW_TRANSITION =
export function createViewTransition(injector: Injector): Promise<void> {
// Create promises outside the Angular zone to avoid causing extra change detections
return injector.get(NgZone).runOutsideAngular(() => {
const document = injector.get(DOCUMENT);
if (!document.startViewTransition) {
return Promise.resolve();
}
Expand Down

0 comments on commit c03baed

Please sign in to comment.