fix(router): openning links in new tab
Clicks on router-link should not prevent browser default action when any mouse button other than left mouse button or ctrl/meta key is pressed. router-link href should use location strategy external url. Closes #5908 Closes #6806 Closes #7749 Closes #8806 Closes #8821
This commit is contained in:

committed by
Misko Hevery

parent
172a5663ef
commit
fa2ce8100b
@ -26,8 +26,8 @@ import {
|
||||
OnActivate,
|
||||
CanDeactivate
|
||||
} from '@angular/router';
|
||||
import {Location} from '@angular/common';
|
||||
import {SpyLocation} from '@angular/common/testing';
|
||||
import {Location, LocationStrategy} from '@angular/common';
|
||||
import {SpyLocation, MockLocationStrategy} from '@angular/common/testing';
|
||||
|
||||
export function main() {
|
||||
describe('RouterLink', () => {
|
||||
@ -35,6 +35,7 @@ export function main() {
|
||||
provide(RouterUrlSerializer, {useClass: DefaultRouterUrlSerializer}),
|
||||
RouterOutletMap,
|
||||
provide(Location, {useClass: SpyLocation}),
|
||||
provide(LocationStrategy, {useClass: MockLocationStrategy}),
|
||||
provide(Router,
|
||||
{
|
||||
useFactory: (resolver, urlParser, outletMap, location) => new Router(
|
||||
@ -44,14 +45,14 @@ export function main() {
|
||||
]);
|
||||
|
||||
describe("routerLink=", () => {
|
||||
it("should accept an array of commands", inject([Router], (router) => {
|
||||
let link = new RouterLink(null, router);
|
||||
it("should accept an array of commands", inject([Router, LocationStrategy], (router, locationStrategy) => {
|
||||
let link = new RouterLink(null, router, locationStrategy);
|
||||
link.routerLink = ['/one', 11];
|
||||
expect(link.href).toEqual("/one/11");
|
||||
}));
|
||||
|
||||
it("should accept a single command", inject([Router], (router) => {
|
||||
let link = new RouterLink(null, router);
|
||||
it("should accept a single command", inject([Router, LocationStrategy], (router, locationStrategy) => {
|
||||
let link = new RouterLink(null, router, locationStrategy);
|
||||
link.routerLink = '/one/11';
|
||||
expect(link.href).toEqual("/one/11");
|
||||
}));
|
||||
@ -61,4 +62,4 @@ export function main() {
|
||||
|
||||
@Component({template: ''})
|
||||
class RootCmp {
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user