fix(router): prevent RouterLinkActive from causing an infinite CD loop

fixes #15825
This commit is contained in:
Victor Berchet
2017-04-12 16:31:02 -07:00
committed by Tobias Bosch
parent 5b141fbf27
commit 82417b3ca5
3 changed files with 78 additions and 5 deletions

View File

@ -123,10 +123,9 @@ export class RouterLinkActive implements OnChanges,
// react only when status has changed to prevent unnecessary dom updates
if (this.active !== hasActiveLinks) {
this.active = hasActiveLinks;
this.classes.forEach(
c => this.renderer.setElementClass(this.element.nativeElement, c, hasActiveLinks));
this.cdr.detectChanges();
Promise.resolve(hasActiveLinks).then(active => this.active = active);
}
}