From 4efe5000c0e0a1d9b67eb152ae65d995b5674fa2 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Mon, 10 Jun 2024 13:58:16 -0700 Subject: [PATCH] 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 --- goldens/public-api/router/index.api.md | 2 +- packages/router/src/directives/router_link.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/goldens/public-api/router/index.api.md b/goldens/public-api/router/index.api.md index e4040076a74..f903ca61979 100644 --- a/goldens/public-api/router/index.api.md +++ b/goldens/public-api/router/index.api.md @@ -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) diff --git a/packages/router/src/directives/router_link.ts b/packages/router/src/directives/router_link.ts index d54246bf700..f898e20addf 100644 --- a/packages/router/src/directives/router_link.ts +++ b/packages/router/src/directives/router_link.ts @@ -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) &&