File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -167,9 +167,13 @@ export class ViewService {
167
167
let uiViewsByFqn : TypedMap < ActiveUIView > =
168
168
this . _uiViews . map ( uiv => [ uiv . fqn , uiv ] ) . reduce ( applyPairs , < any > { } ) ;
169
169
170
- // Return the number of dots in the fully qualified name
170
+ // Return a weighted depth value for a uiView.
171
+ // The depth is the nesting depth of ui-views (based on FQN; times 10,000)
172
+ // plus the depth of the state that is populating the uiView
171
173
function uiViewDepth ( uiView : ActiveUIView ) {
172
- return uiView . fqn . split ( "." ) . length ;
174
+ const stateDepth = ( context : ViewContext ) =>
175
+ context . parent ? stateDepth ( context . parent ) + 1 : 1 ;
176
+ return ( uiView . fqn . split ( "." ) . length * 10000 ) + stateDepth ( uiView . creationContext ) ;
173
177
}
174
178
175
179
// Return the ViewConfig's context's depth in the context tree.
@@ -200,6 +204,7 @@ export class ViewService {
200
204
uiView . configUpdated ( viewConfig ) ;
201
205
} ;
202
206
207
+ // Sort views by FQN and state depth. Process uiviews nearest the root first.
203
208
this . _uiViews . sort ( depthCompare ( uiViewDepth , 1 ) ) . map ( matchingConfigPair ) . forEach ( configureUIView ) ;
204
209
} ;
205
210
You can’t perform that action at this time.
0 commit comments