fix(router): add null support for RouterLink directive (#32616)

Value of "undefined" passed as segment in routerLink is stringified to string "undefined".
This change introduces the same behavior for value of "null".

PR Close #32616
This commit is contained in:
Krzysztof Grzybek
2019-09-11 20:38:56 +02:00
committed by Andrew Kushnir
parent 3190ccf3b2
commit 69948ce919
3 changed files with 52 additions and 5 deletions

View File

@ -1994,6 +1994,36 @@ describe('Integration', () => {
expect(() => buttons[1].click()).not.toThrow();
}));
it('should not throw when some command is null', fakeAsync(() => {
@Component({
selector: 'someCmp',
template:
`<router-outlet></router-outlet><a [routerLink]="[null]">Link</a><button [routerLink]="[null]">Button</button>`
})
class CmpWithLink {
}
TestBed.configureTestingModule({declarations: [CmpWithLink]});
const router: Router = TestBed.inject(Router);
expect(() => createRoot(router, CmpWithLink)).not.toThrow();
}));
it('should not throw when some command is undefined', fakeAsync(() => {
@Component({
selector: 'someCmp',
template:
`<router-outlet></router-outlet><a [routerLink]="[undefined]">Link</a><button [routerLink]="[undefined]">Button</button>`
})
class CmpWithLink {
}
TestBed.configureTestingModule({declarations: [CmpWithLink]});
const router: Router = TestBed.inject(Router);
expect(() => createRoot(router, CmpWithLink)).not.toThrow();
}));
it('should update hrefs when query params or fragment change', fakeAsync(() => {
@Component({
selector: 'someRoot',