fix(router): set href when routerLink is used on an 'area' element (#28441)
closes #28401 PR Close #28441
This commit is contained in:
parent
4ceb655c11
commit
ed0cf7e2cb
@ -111,7 +111,7 @@ import {UrlTree} from '../url_tree';
|
|||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
@Directive({selector: ':not(a)[routerLink]'})
|
@Directive({selector: ':not(a):not(area)[routerLink]'})
|
||||||
export class RouterLink {
|
export class RouterLink {
|
||||||
// TODO(issue/24571): remove '!'.
|
// TODO(issue/24571): remove '!'.
|
||||||
@Input() queryParams !: {[k: string]: any};
|
@Input() queryParams !: {[k: string]: any};
|
||||||
@ -191,7 +191,7 @@ export class RouterLink {
|
|||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
@Directive({selector: 'a[routerLink]'})
|
@Directive({selector: 'a[routerLink],area[routerLink]'})
|
||||||
export class RouterLinkWithHref implements OnChanges, OnDestroy {
|
export class RouterLinkWithHref implements OnChanges, OnDestroy {
|
||||||
// TODO(issue/24571): remove '!'.
|
// TODO(issue/24571): remove '!'.
|
||||||
@HostBinding('attr.target') @Input() target !: string;
|
@HostBinding('attr.target') @Input() target !: string;
|
||||||
|
@ -1939,6 +1939,25 @@ describe('Integration', () => {
|
|||||||
expect(history[history.length - 1].state)
|
expect(history[history.length - 1].state)
|
||||||
.toEqual({foo: 'bar', navigationId: history.length});
|
.toEqual({foo: 'bar', navigationId: history.length});
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
it('should set href on area elements', fakeAsync(() => {
|
||||||
|
@Component({
|
||||||
|
selector: 'someRoot',
|
||||||
|
template: `<router-outlet></router-outlet><map><area routerLink="/home" /></map>`
|
||||||
|
})
|
||||||
|
class RootCmpWithArea {
|
||||||
|
}
|
||||||
|
|
||||||
|
TestBed.configureTestingModule({declarations: [RootCmpWithArea]});
|
||||||
|
const router: Router = TestBed.get(Router);
|
||||||
|
|
||||||
|
const fixture = createRoot(router, RootCmpWithArea);
|
||||||
|
|
||||||
|
router.resetConfig([{path: 'home', component: SimpleCmp}]);
|
||||||
|
|
||||||
|
const native = fixture.nativeElement.querySelector('area');
|
||||||
|
expect(native.getAttribute('href')).toEqual('/home');
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('redirects', () => {
|
describe('redirects', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user