@@ -181,7 +181,7 @@ export type NavigationTransition = {
181181 reject : any ,
182182 promise : Promise < boolean > ,
183183 source : NavigationTrigger ,
184- state : { navigationId : number } | null ,
184+ restoredState : { navigationId : number } | null ,
185185 currentSnapshot : RouterStateSnapshot ,
186186 targetSnapshot : RouterStateSnapshot | null ,
187187 currentRouterState : RouterState ,
@@ -351,7 +351,7 @@ export class Router {
351351 reject : null ,
352352 promise : Promise . resolve ( true ) ,
353353 source : 'imperative' ,
354- state : null ,
354+ restoredState : null ,
355355 currentSnapshot : this . routerState . snapshot ,
356356 targetSnapshot : null ,
357357 currentRouterState : this . routerState ,
@@ -393,7 +393,7 @@ export class Router {
393393 switchMap ( t => {
394394 const transition = this . transitions . getValue ( ) ;
395395 eventsSubject . next ( new NavigationStart (
396- t . id , this . serializeUrl ( t . extractedUrl ) , t . source , t . state ) ) ;
396+ t . id , this . serializeUrl ( t . extractedUrl ) , t . source , t . restoredState ) ) ;
397397 if ( transition !== this . transitions . getValue ( ) ) {
398398 return EMPTY ;
399399 }
@@ -431,9 +431,9 @@ export class Router {
431431 * handle this "error condition" by navigating to the previously successful URL,
432432 * but leaving the URL intact.*/
433433 if ( processPreviousUrl ) {
434- const { id, extractedUrl, source, state , extras} = t ;
435- const navStart =
436- new NavigationStart ( id , this . serializeUrl ( extractedUrl ) , source , state ) ;
434+ const { id, extractedUrl, source, restoredState , extras} = t ;
435+ const navStart = new NavigationStart (
436+ id , this . serializeUrl ( extractedUrl ) , source , restoredState ) ;
437437 eventsSubject . next ( navStart ) ;
438438 const targetSnapshot =
439439 createEmptyState ( extractedUrl , this . rootComponentType ) . snapshot ;
@@ -681,9 +681,9 @@ export class Router {
681681 this . locationSubscription = < any > this . location . subscribe ( ( change : any ) => {
682682 let rawUrlTree = this . parseUrl ( change [ 'url' ] ) ;
683683 const source : NavigationTrigger = change [ 'type' ] === 'popstate' ? 'popstate' : 'hashchange' ;
684- const state = change . state && change . state . navigationId ?
685- { navigationId : change . state . navigationId } :
686- null ;
684+ // Navigations coming from Angular router have a navigationId state property. When this
685+ // exists, restore the state.
686+ const state = change . state && change . state . navigationId ? change . state : null ;
687687 setTimeout (
688688 ( ) => { this . scheduleNavigation ( rawUrlTree , source , state , { replaceUrl : true } ) ; } , 0 ) ;
689689 } ) ;
@@ -917,7 +917,7 @@ export class Router {
917917 }
918918
919919 private scheduleNavigation (
920- rawUrl : UrlTree , source : NavigationTrigger , state : { navigationId : number } | null ,
920+ rawUrl : UrlTree , source : NavigationTrigger , restoredState : { navigationId : number } | null ,
921921 extras : NavigationExtras ) : Promise < boolean > {
922922 const lastNavigation = this . getTransition ( ) ;
923923 // If the user triggers a navigation imperatively (e.g., by using navigateByUrl),
@@ -955,7 +955,7 @@ export class Router {
955955 this . setTransition ( {
956956 id,
957957 source,
958- state ,
958+ restoredState ,
959959 currentUrlTree : this . currentUrlTree ,
960960 currentRawUrl : this . rawUrlTree , rawUrl, extras, resolve, reject, promise,
961961 currentSnapshot : this . routerState . snapshot ,
0 commit comments