( route: ActivatedRouteSnapshot, parent: ActivatedRouteSnapshot | null, paramsInheritanceStrategy: ParamsInheritanceStrategy, )
| 311 | * route is component-less. |
| 312 | */ |
| 313 | export function getInherited( |
| 314 | route: ActivatedRouteSnapshot, |
| 315 | parent: ActivatedRouteSnapshot | null, |
| 316 | paramsInheritanceStrategy: ParamsInheritanceStrategy, |
| 317 | ): Inherited { |
| 318 | let inherited: Inherited; |
| 319 | const {routeConfig} = route; |
| 320 | if ( |
| 321 | parent !== null && |
| 322 | (paramsInheritanceStrategy === 'always' || |
| 323 | // inherit parent data if route is empty path |
| 324 | routeConfig?.path === '' || |
| 325 | // inherit parent data if parent was componentless |
| 326 | (!parent.component && !parent.routeConfig?.loadComponent)) |
| 327 | ) { |
| 328 | inherited = { |
| 329 | params: {...parent.params, ...route.params}, |
| 330 | data: {...parent.data, ...route.data}, |
| 331 | resolve: { |
| 332 | // Snapshots are created with data inherited from parent and guards (i.e. canActivate) can |
| 333 | // change data because it's not frozen... |
| 334 | // This first line could be deleted chose to break/disallow mutating the `data` object in |
| 335 | // guards. |
| 336 | // Note that data from parents still override this mutated data so anyone relying on this |
| 337 | // might be surprised that it doesn't work if parent data is inherited but otherwise does. |
| 338 | ...route.data, |
| 339 | // Ensure inherited resolved data overrides inherited static data |
| 340 | ...parent.data, |
| 341 | // static data from the current route overrides any inherited data |
| 342 | ...routeConfig?.data, |
| 343 | // resolved data from current route overrides everything |
| 344 | ...route._resolvedData, |
| 345 | }, |
| 346 | }; |
| 347 | } else { |
| 348 | inherited = { |
| 349 | params: {...route.params}, |
| 350 | data: {...route.data}, |
| 351 | resolve: {...route.data, ...(route._resolvedData ?? {})}, |
| 352 | }; |
| 353 | } |
| 354 | |
| 355 | if (routeConfig && hasStaticTitle(routeConfig)) { |
| 356 | inherited.resolve[RouteTitleKey] = routeConfig.title; |
| 357 | } |
| 358 | return inherited; |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * @description |
no test coverage detected