Skip to content

Commit 7a5d083

Browse files
committed
refactor(router): Use for...of rather than mapChildrenIntoArray helper (angular#40029)
When stepping through the `recognize` algorithm, it is much easier to follow when using a simple `for...of` rather than the helper `mapChildrenIntoArray` with the passed closure. The only special thing that `mapChildrenIntoArray` does is ensure the primary route appears first. This change will have no affect on the result because `processChildren` later calls `sortActivatedRouteSnapshots`, which does the same thing. PR Close angular#40029
1 parent 7e583ab commit 7a5d083

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎packages/router/src/recognize.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ class Recognizer {
7979

8080
processChildren(config: Route[], segmentGroup: UrlSegmentGroup):
8181
TreeNode<ActivatedRouteSnapshot>[] {
82-
const children = mapChildrenIntoArray(
83-
segmentGroup, (child, childOutlet) => this.processSegmentGroup(config, child, childOutlet));
82+
const children: Array<TreeNode<ActivatedRouteSnapshot>> = [];
83+
for (const childOutlet of Object.keys(segmentGroup.children)) {
84+
const child = segmentGroup.children[childOutlet];
85+
children.push(...this.processSegmentGroup(config, child, childOutlet));
86+
}
8487
checkOutletNameUniqueness(children);
8588
sortActivatedRouteSnapshots(children);
8689
return children;

0 commit comments

Comments
 (0)