Skip to content

Commit

Permalink
fix($location): don't call indexOf() of undefined href attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
caitp committed Aug 19, 2014
1 parent b7e82a3 commit 4f8cc19
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ function $LocationProvider(){
// http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx
var href = elm.attr('href') || elm.attr('xlink:href');

if (href.indexOf('://') < 0) { // Ignore absolute URLs
if (/*href &&*/ href.indexOf('://') < 0) { // Ignore absolute URLs
var prefix = '#' + hashPrefix;
if (href[0] == '/') {
// absolute path - replace old path
Expand Down
18 changes: 18 additions & 0 deletions test/ng/directive/ngEventDirsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,22 @@ describe('event directives', function() {
expect($rootScope.formSubmitted).toEqual('foo');
}));
});


describe('ngClick', function() {
// Regression (gh-7721)
it('should be evaluated on anchor elements with no href in html5 mode', function() {
module(function($locationProvider) {
$locationProvider.html5Mode(true);
});
inject(function($rootScope, $compile) {
$rootScope.i = 0;
element = $compile('<a ng-click="i = i + 1">anchor</a>')($rootScope);

browserTrigger(element);

expect($rootScope.i).toBe(1);
});
});
});
});

0 comments on commit 4f8cc19

Please sign in to comment.