@@ -3,7 +3,7 @@ import { Transition } from '../transition/transition';
3
3
import { UIRouter } from '../router' ;
4
4
import { TransitionService } from '../transition/transitionService' ;
5
5
import { Resolvable } from '../resolve' ;
6
- import { extend , inArray , map , mapObj , unnestR , values } from '../common' ;
6
+ import { extend , inArray , map , mapObj , uniqR , unnestR , values } from '../common' ;
7
7
import { PathNode } from '../path' ;
8
8
import { TreeChanges } from "../transition" ;
9
9
@@ -29,15 +29,14 @@ const isTransition = inArray(TRANSITION_TOKENS);
29
29
// This function removes resolves for '$transition$' and `Transition` from the treeChanges.
30
30
// Do not use this on current transitions, only on old ones.
31
31
export const treeChangesCleanup = ( trans : Transition ) => {
32
+ const nodes = values ( trans . treeChanges ( ) ) . reduce ( unnestR , [ ] ) . reduce ( uniqR , [ ] ) ;
33
+
32
34
// 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
+ } ;
35
38
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 ) ;
39
41
} ) ;
40
-
41
- const treeChanges : TreeChanges = trans . treeChanges ( ) ;
42
- mapObj ( treeChanges , cleanPath , treeChanges ) ;
43
42
} ;
0 commit comments