refactor(router): Use for...of rather than `mapChildrenIntoArray` helper (#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 #40029
This commit is contained in:
Andrew Scott 2020-11-25 17:19:43 -08:00 committed by Joey Perrott
parent b473bc226c
commit 77f47da016
1 changed files with 5 additions and 2 deletions

View File

@ -79,8 +79,11 @@ class Recognizer {
processChildren(config: Route[], segmentGroup: UrlSegmentGroup):
TreeNode<ActivatedRouteSnapshot>[] {
const children = mapChildrenIntoArray(
segmentGroup, (child, childOutlet) => this.processSegmentGroup(config, child, childOutlet));
const children: Array<TreeNode<ActivatedRouteSnapshot>> = [];
for (const childOutlet of Object.keys(segmentGroup.children)) {
const child = segmentGroup.children[childOutlet];
children.push(...this.processSegmentGroup(config, child, childOutlet));
}
checkOutletNameUniqueness(children);
sortActivatedRouteSnapshots(children);
return children;