fix(router): ensure check for match options is compatible with property renaming (#43086)
After renaming, 'paths' is not in routerLinkOptions since it's been renamed. PR Close #43086
This commit is contained in:
parent
04879a1007
commit
bbad42310b
|
@ -168,7 +168,8 @@ export class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit
|
||||||
}
|
}
|
||||||
|
|
||||||
private isLinkActive(router: Router): (link: (RouterLink|RouterLinkWithHref)) => boolean {
|
private isLinkActive(router: Router): (link: (RouterLink|RouterLinkWithHref)) => boolean {
|
||||||
const options = 'paths' in this.routerLinkActiveOptions ?
|
const options: boolean|IsActiveMatchOptions =
|
||||||
|
isActiveMatchOptions(this.routerLinkActiveOptions) ?
|
||||||
this.routerLinkActiveOptions :
|
this.routerLinkActiveOptions :
|
||||||
// While the types should disallow `undefined` here, it's possible without strict inputs
|
// While the types should disallow `undefined` here, it's possible without strict inputs
|
||||||
(this.routerLinkActiveOptions.exact || false);
|
(this.routerLinkActiveOptions.exact || false);
|
||||||
|
@ -182,3 +183,11 @@ export class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit
|
||||||
this.links.some(isActiveCheckFn) || this.linksWithHrefs.some(isActiveCheckFn);
|
this.links.some(isActiveCheckFn) || this.linksWithHrefs.some(isActiveCheckFn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use instead of `'paths' in options` to be compatible with property renaming
|
||||||
|
*/
|
||||||
|
function isActiveMatchOptions(options: {exact: boolean}|
|
||||||
|
IsActiveMatchOptions): options is IsActiveMatchOptions {
|
||||||
|
return !!(options as IsActiveMatchOptions).paths;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue