* Finds `TreeNode`s with matching empty path route configs and merges them into `TreeNode` with * the children from each duplicate. This is necessary because different outlets can match a * single empty path route config and the results need to then be merged.
( nodes: Array<TreeNode<ActivatedRouteSnapshot>>, )
| 550 | * single empty path route config and the results need to then be merged. |
| 551 | */ |
| 552 | function mergeEmptyPathMatches( |
| 553 | nodes: Array<TreeNode<ActivatedRouteSnapshot>>, |
| 554 | ): Array<TreeNode<ActivatedRouteSnapshot>> { |
| 555 | const result: Array<TreeNode<ActivatedRouteSnapshot>> = []; |
| 556 | // The set of nodes which contain children that were merged from two duplicate empty path nodes. |
| 557 | const mergedNodes: Set<TreeNode<ActivatedRouteSnapshot>> = new Set(); |
| 558 | |
| 559 | for (const node of nodes) { |
| 560 | if (!hasEmptyPathConfig(node)) { |
| 561 | result.push(node); |
| 562 | continue; |
| 563 | } |
| 564 | |
| 565 | const duplicateEmptyPathNode = result.find( |
| 566 | (resultNode) => node.value.routeConfig === resultNode.value.routeConfig, |
| 567 | ); |
| 568 | if (duplicateEmptyPathNode !== undefined) { |
| 569 | duplicateEmptyPathNode.children.push(...node.children); |
| 570 | mergedNodes.add(duplicateEmptyPathNode); |
| 571 | } else { |
| 572 | result.push(node); |
| 573 | } |
| 574 | } |
| 575 | // For each node which has children from multiple sources, we need to recompute a new `TreeNode` |
| 576 | // by also merging those children. This is necessary when there are multiple empty path configs |
| 577 | // in a row. Put another way: whenever we combine children of two nodes, we need to also check |
| 578 | // if any of those children can be combined into a single node as well. |
| 579 | for (const mergedNode of mergedNodes) { |
| 580 | const mergedChildren = mergeEmptyPathMatches(mergedNode.children); |
| 581 | result.push(new TreeNode(mergedNode.value, mergedChildren)); |
| 582 | } |
| 583 | return result.filter((n) => !mergedNodes.has(n)); |
| 584 | } |
| 585 | |
| 586 | function checkOutletNameUniqueness(nodes: TreeNode<ActivatedRouteSnapshot>[]): void { |
| 587 | const names: {[k: string]: ActivatedRouteSnapshot} = {}; |
no test coverage detected
searching dependent graphs…