Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit dbdd5f3

Browse files
committed
fix(1.x/aDirective): handle anchor elts with no href
Closes #206
1 parent 169f417 commit dbdd5f3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/grammar.ats

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class Grammar {
2121
}
2222

2323
recognize(url:string, componentName = '/') {
24+
if (typeof url === 'undefined') {
25+
return;
26+
}
2427

2528
var componentRecognizer = this.rules[componentName];
2629
if (!componentRecognizer) {

test/router-viewport.es5.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,21 @@ describe('ngViewport', function () {
543543
expect(elt.text()).toBe('link | two');
544544
});
545545

546+
// See https://github.com/angular/router/issues/206
547+
it('should not navigate a link without an href', function () {
548+
$router.config([
549+
{ path: '/', component: 'one' },
550+
{ path: '/two', component: 'two' },
551+
]);
552+
expect(function() {
553+
compile('<a>link</a>');
554+
$rootScope.$digest();
555+
expect(elt.text()).toBe('link');
556+
elt.find('a')[0].click();
557+
$rootScope.$digest();
558+
}).not.toThrow();
559+
});
560+
546561

547562
it('should change location to the canonical route', inject(function ($location) {
548563
compile('<div ng-viewport></div>');

0 commit comments

Comments
 (0)