@@ -3,7 +3,7 @@ import { Transition } from '../transition/transition';
33import { UIRouter } from '../router' ;
44import { TransitionService } from '../transition/transitionService' ;
55import { Resolvable } from '../resolve' ;
6- import { extend , inArray , map , mapObj , unnestR , values } from '../common' ;
6+ import { extend , inArray , map , mapObj , uniqR , unnestR , values } from '../common' ;
77import { PathNode } from '../path' ;
88import { TreeChanges } from "../transition" ;
99
@@ -29,15 +29,14 @@ const isTransition = inArray(TRANSITION_TOKENS);
2929// This function removes resolves for '$transition$' and `Transition` from the treeChanges.
3030// Do not use this on current transitions, only on old ones.
3131export const treeChangesCleanup = ( trans : Transition ) => {
32+ const nodes = values ( trans . treeChanges ( ) ) . reduce ( unnestR , [ ] ) . reduce ( uniqR , [ ] ) ;
33+
3234 // If the resolvable is a Transition, return a new resolvable with null data
33- const replaceTransitionWithNull = ( r : Resolvable ) : Resolvable =>
34- isTransition ( r . token ) ? Resolvable . fromData ( r . token , null ) : r ;
35+ const replaceTransitionWithNull = ( r : Resolvable ) : Resolvable => {
36+ return isTransition ( r . token ) ? Resolvable . fromData ( r . token , null ) : r ;
37+ } ;
3538
36- const cleanPath = ( path : PathNode [ ] ) => path . map ( ( node : PathNode ) => {
37- const resolvables = node . resolvables . map ( replaceTransitionWithNull ) ;
38- return extend ( node . clone ( ) , { resolvables } ) ;
39+ nodes . forEach ( ( node : PathNode ) => {
40+ node . resolvables = node . resolvables . map ( replaceTransitionWithNull ) ;
3941 } ) ;
40-
41- const treeChanges : TreeChanges = trans . treeChanges ( ) ;
42- mapObj ( treeChanges , cleanPath , treeChanges ) ;
4342} ;
0 commit comments