fix(router): RouterLink mirrors input `target` as attribute
Closes #13837
This commit is contained in:
parent
fb6c4582a1
commit
d9a22dae4f
|
@ -139,7 +139,7 @@ export class RouterLink {
|
||||||
*/
|
*/
|
||||||
@Directive({selector: 'a[routerLink]'})
|
@Directive({selector: 'a[routerLink]'})
|
||||||
export class RouterLinkWithHref implements OnChanges, OnDestroy {
|
export class RouterLinkWithHref implements OnChanges, OnDestroy {
|
||||||
@Input() target: string;
|
@HostBinding('attr.target') @Input() target: string;
|
||||||
@Input() queryParams: {[k: string]: any};
|
@Input() queryParams: {[k: string]: any};
|
||||||
@Input() fragment: string;
|
@Input() fragment: string;
|
||||||
@Input() preserveQueryParams: boolean;
|
@Input() preserveQueryParams: boolean;
|
||||||
|
|
|
@ -998,6 +998,7 @@ describe('Integration', () => {
|
||||||
|
|
||||||
const native = fixture.nativeElement.querySelector('a');
|
const native = fixture.nativeElement.querySelector('a');
|
||||||
expect(native.getAttribute('href')).toEqual('/team/33/simple');
|
expect(native.getAttribute('href')).toEqual('/team/33/simple');
|
||||||
|
expect(native.getAttribute('target')).toEqual('_self');
|
||||||
native.click();
|
native.click();
|
||||||
advance(fixture);
|
advance(fixture);
|
||||||
|
|
||||||
|
@ -2710,7 +2711,8 @@ function expectEvents(events: Event[], pairs: any[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'link-cmp', template: `<a routerLink="/team/33/simple">link</a>`})
|
@Component(
|
||||||
|
{selector: 'link-cmp', template: `<a routerLink="/team/33/simple" [target]="'_self'">link</a>`})
|
||||||
class StringLinkCmp {
|
class StringLinkCmp {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue