(
button: number,
ctrlKey: boolean,
shiftKey: boolean,
altKey: boolean,
metaKey: boolean,
)
| 506 | '$event.metaKey', |
| 507 | ]) |
| 508 | onClick( |
| 509 | button: number, |
| 510 | ctrlKey: boolean, |
| 511 | shiftKey: boolean, |
| 512 | altKey: boolean, |
| 513 | metaKey: boolean, |
| 514 | ): boolean { |
| 515 | const urlTree = this.urlTree; |
| 516 | |
| 517 | if (urlTree === null) { |
| 518 | return true; |
| 519 | } |
| 520 | |
| 521 | if (this.isAnchorElement) { |
| 522 | if (button !== 0 || ctrlKey || shiftKey || altKey || metaKey) { |
| 523 | return true; |
| 524 | } |
| 525 | |
| 526 | if (typeof this.target === 'string' && this.target != '_self') { |
| 527 | return true; |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | const browserUrl = this.browserUrl(); |
| 532 | const scroll = this.scroll(); |
| 533 | const extras = { |
| 534 | skipLocationChange: this.skipLocationChange, |
| 535 | replaceUrl: this.replaceUrl, |
| 536 | state: this.state, |
| 537 | info: this.info, |
| 538 | // TODO: Remove conditional spread once all consumers handle `browserUrl`. |
| 539 | // Having this property always set broke some tests in G3. |
| 540 | ...(browserUrl !== undefined && {browserUrl}), |
| 541 | // Same for `scroll`, so the extras are unchanged when the input isn't used. |
| 542 | ...(scroll !== undefined && {scroll}), |
| 543 | }; |
| 544 | // navigateByUrl is mocked frequently in tests... Reduce breakages when |
| 545 | // adding `catch` |
| 546 | this.router.navigateByUrl(urlTree, extras)?.catch((e) => { |
| 547 | this.applicationErrorHandler(e); |
| 548 | }); |
| 549 | |
| 550 | // Return `false` for `<a>` elements to prevent default action |
| 551 | // and cancel the native behavior, since the navigation is handled |
| 552 | // by the Router. |
| 553 | return !this.isAnchorElement; |
| 554 | } |
| 555 | |
| 556 | /** @docs-private */ |
| 557 | ngOnDestroy(): any {} |
nothing calls this directly
no test coverage detected