(
futureNode: TreeNode<ActivatedRouteSnapshot>,
currNode: TreeNode<ActivatedRouteSnapshot>,
parentContexts: ChildrenOutletContexts | null,
futurePath: ActivatedRouteSnapshot[],
checks: Checks = {
canDeactivateChecks: [],
canActivateChecks: [],
},
)
| 108 | } |
| 109 | |
| 110 | function getRouteGuards( |
| 111 | futureNode: TreeNode<ActivatedRouteSnapshot>, |
| 112 | currNode: TreeNode<ActivatedRouteSnapshot>, |
| 113 | parentContexts: ChildrenOutletContexts | null, |
| 114 | futurePath: ActivatedRouteSnapshot[], |
| 115 | checks: Checks = { |
| 116 | canDeactivateChecks: [], |
| 117 | canActivateChecks: [], |
| 118 | }, |
| 119 | ): Checks { |
| 120 | const future = futureNode.value; |
| 121 | const curr = currNode ? currNode.value : null; |
| 122 | const context = parentContexts ? parentContexts.getContext(futureNode.value.outlet) : null; |
| 123 | |
| 124 | // reusing the node |
| 125 | if (curr && future.routeConfig === curr.routeConfig) { |
| 126 | const shouldRun = shouldRunGuardsAndResolvers( |
| 127 | curr, |
| 128 | future, |
| 129 | future.routeConfig!.runGuardsAndResolvers, |
| 130 | ); |
| 131 | if (shouldRun) { |
| 132 | checks.canActivateChecks.push(new CanActivate(futurePath)); |
| 133 | } else { |
| 134 | // we need to set the data |
| 135 | future.data = curr.data; |
| 136 | future._resolvedData = curr._resolvedData; |
| 137 | } |
| 138 | |
| 139 | // If we have a component, we need to go through an outlet. |
| 140 | if (future.component) { |
| 141 | getChildRouteGuards( |
| 142 | futureNode, |
| 143 | currNode, |
| 144 | context ? context.children : null, |
| 145 | futurePath, |
| 146 | checks, |
| 147 | ); |
| 148 | |
| 149 | // if we have a componentless route, we recurse but keep the same outlet map. |
| 150 | } else { |
| 151 | getChildRouteGuards(futureNode, currNode, parentContexts, futurePath, checks); |
| 152 | } |
| 153 | |
| 154 | if (shouldRun && context && context.outlet && context.outlet.isActivated) { |
| 155 | checks.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, curr)); |
| 156 | } |
| 157 | } else { |
| 158 | if (curr) { |
| 159 | deactivateRouteAndItsChildren(currNode, context, checks); |
| 160 | } |
| 161 | |
| 162 | checks.canActivateChecks.push(new CanActivate(futurePath)); |
| 163 | // If we have a component, we need to go through an outlet. |
| 164 | if (future.component) { |
| 165 | getChildRouteGuards(futureNode, null, context ? context.children : null, futurePath, checks); |
| 166 | |
| 167 | // if we have a componentless route, we recurse but keep the same outlet map. |
no test coverage detected
searching dependent graphs…