Skip to content

Commit 7677578

Browse files
atscottAndrewKushnir
authored andcommitted
refactor(router): Add safe navigation operator (angular#60314)
Adds safe navigation operator to account for tests spying on navigateByUrl PR Close angular#60314
1 parent ef1fd13 commit 7677578

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/router/src/directives/router_link.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ export class RouterLink implements OnChanges, OnDestroy {
353353
state: this.state,
354354
info: this.info,
355355
};
356-
this.router.navigateByUrl(urlTree, extras).catch((e) => {
356+
// navigateByUrl is mocked frequently in tests... Reduce breakages when adding `catch`
357+
this.router.navigateByUrl(urlTree, extras)?.catch((e) => {
357358
this.applicationErrorHandler(e);
358359
});
359360

0 commit comments

Comments
 (0)