1
1
/** @module path */ /** for typedoc */
2
2
3
- import { extend , find , pick , omit , tail , mergeR , values , unnestR , Predicate } from "../common/common" ;
3
+ import { extend , find , pick , omit , tail , mergeR , values , unnestR , Predicate , inArray } from "../common/common" ;
4
4
import { prop , propEq , not } from "../common/hof" ;
5
5
6
6
import { RawParams } from "../params/interface" ;
@@ -11,7 +11,6 @@ import {_ViewDeclaration} from "../state/interface";
11
11
import { State } from "../state/stateObject" ;
12
12
import { TargetState } from "../state/targetState" ;
13
13
import { PathNode } from "../path/node" ;
14
- import { ResolveContext } from "../resolve/resolveContext" ;
15
14
import { ViewService } from "../view/view" ;
16
15
17
16
/**
@@ -46,13 +45,13 @@ export class PathFactory {
46
45
*
47
46
* On each [[PathNode]], creates ViewConfig objects from the views: property of the node's state
48
47
*/
49
- static applyViewConfigs ( $view : ViewService , path : PathNode [ ] ) {
50
- return path . map ( node => {
51
- let subPath = PathFactory . subPath ( path , n => n === node ) ;
48
+ static applyViewConfigs ( $view : ViewService , path : PathNode [ ] , states : State [ ] ) {
49
+ // Only apply the viewConfigs to the nodes for the given states
50
+ path . filter ( node => inArray ( states , node . state ) ) . forEach ( node => {
52
51
let viewDecls : _ViewDeclaration [ ] = values ( node . state . views || { } ) ;
52
+ let subPath = PathFactory . subPath ( path , n => n === node ) ;
53
53
let viewConfigs : ViewConfig [ ] [ ] = viewDecls . map ( view => $view . createViewConfig ( subPath , view ) ) ;
54
54
node . views = viewConfigs . reduce ( unnestR , [ ] ) ;
55
- return node ;
56
55
} ) ;
57
56
}
58
57
0 commit comments