diff --git a/src/ng/location.js b/src/ng/location.js index 402db3cf04d5..12f6c14cc0cb 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -629,6 +629,13 @@ function $LocationProvider(){ } var absHref = elm.prop('href'); + + if (isObject(absHref) && absHref.toString() === '[object SVGAnimatedString]') { + // SVGAnimatedString.animVal should be identical to SVGAnimatedString.baseVal, unless during + // an animation. + absHref = urlResolve(absHref.animVal).href; + } + var rewrittenUrl = $location.$$rewrite(absHref); if (absHref && !elm.attr('target') && rewrittenUrl && !event.isDefaultPrevented()) { diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index b9dd17fa505d..f23965f80ee5 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -1229,6 +1229,31 @@ describe('$location', function() { }); browserTrigger(button, 'click'); })); + + + it('should not throw when clicking an SVGAElement link', function() { + var base; + module(function($locationProvider) { + return function($browser) { + window.location.hash = '!someHash'; + $browser.url(base = window.location.href); + base = base.split('#')[0]; + $locationProvider.hashPrefix('!'); + } + }); + inject(function($rootScope, $compile, $browser, $rootElement, $document, $location) { + // we need to do this otherwise we can't simulate events + $document.find('body').append($rootElement); + var template = ''; + var element = $compile(template)($rootScope); + + $rootElement.append(element); + var av1 = $rootElement.find('a').eq(0); + expect(function() { + browserTrigger(av1, 'click'); + }).not.toThrow(); + }); + }); });