refactor(router): Add back changes param to RouterLink ngOnChanges (#56371)

This parameter was removed in a recent change but is being added back to
avoid breaking code in a minor version.
While the changes parameter is not used, some code relies on it, mostly
through API misuse (extending `RouterLink`, manually calling `ngOnChanges`, etc.).

PR Close #56371
This commit is contained in:
Andrew Scott 2024-06-10 13:58:16 -07:00 committed by Andrew Kushnir
parent 3cbddd2e42
commit 4efe5000c0
2 changed files with 4 additions and 2 deletions

View file

@ -810,7 +810,7 @@ class RouterLink implements OnChanges, OnDestroy {
// (undocumented)
static ngAcceptInputType_skipLocationChange: unknown;
// (undocumented)
ngOnChanges(): void;
ngOnChanges(changes?: SimpleChanges): void;
// (undocumented)
ngOnDestroy(): any;
// (undocumented)

View file

@ -19,6 +19,7 @@ import {
OnDestroy,
Renderer2,
ɵRuntimeError as RuntimeError,
SimpleChanges,
ɵɵsanitizeUrlOrResourceUrl,
} from '@angular/core';
import {Subject, Subscription} from 'rxjs';
@ -260,7 +261,8 @@ export class RouterLink implements OnChanges, OnDestroy {
}
/** @nodoc */
ngOnChanges() {
// TODO(atscott): Remove changes parameter in major version as a breaking change.
ngOnChanges(changes?: SimpleChanges) {
if (
ngDevMode &&
isUrlTree(this.routerLinkInput) &&