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

Commit 4f8cc19

Browse files
committed
fix($location): don't call indexOf() of undefined href attribute
Closes #7721
1 parent b7e82a3 commit 4f8cc19

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/ng/location.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ function $LocationProvider(){
670670
// http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx
671671
var href = elm.attr('href') || elm.attr('xlink:href');
672672

673-
if (href.indexOf('://') < 0) { // Ignore absolute URLs
673+
if (/*href &&*/ href.indexOf('://') < 0) { // Ignore absolute URLs
674674
var prefix = '#' + hashPrefix;
675675
if (href[0] == '/') {
676676
// absolute path - replace old path

test/ng/directive/ngEventDirsSpec.js

+18
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,22 @@ describe('event directives', function() {
3939
expect($rootScope.formSubmitted).toEqual('foo');
4040
}));
4141
});
42+
43+
44+
describe('ngClick', function() {
45+
// Regression (gh-7721)
46+
it('should be evaluated on anchor elements with no href in html5 mode', function() {
47+
module(function($locationProvider) {
48+
$locationProvider.html5Mode(true);
49+
});
50+
inject(function($rootScope, $compile) {
51+
$rootScope.i = 0;
52+
element = $compile('<a ng-click="i = i + 1">anchor</a>')($rootScope);
53+
54+
browserTrigger(element);
55+
56+
expect($rootScope.i).toBe(1);
57+
});
58+
});
59+
});
4260
});

0 commit comments

Comments
 (0)