aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/locationSpec.js
diff options
context:
space:
mode:
authorCaitlin Potter2013-12-18 17:12:02 -0500
committerIgor Minar2013-12-18 17:16:39 -0800
commitbc3ff2cecd0861766a9e8606f3cc2c582d9875df (patch)
tree4155ddfca3e881c59463d763e13f4607098557f1 /test/ng/locationSpec.js
parent8f329ffb829410e1fd8f86a766929134e736e3e5 (diff)
downloadangular.js-bc3ff2cecd0861766a9e8606f3cc2c582d9875df.tar.bz2
fix($location): parse xlink:href for SVGAElements
Before this fix, the xlink:href property of an SVG <a> element could not be parsed on click, as the property is an SVGAnimatedString rather than a DOMString. This patch parses the xlink:href's animVal into a DOMString in order to prevent an `Object #<SVGAnimatedString> has no method 'indexOf'` exception from being thrown, and also to update the location if necessary as expected. Closes #5472 Closes #5198 Closes #5199 Closes #4098 Closes #1420
Diffstat (limited to 'test/ng/locationSpec.js')
-rw-r--r--test/ng/locationSpec.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js
index b9dd17fa..f23965f8 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 = '<svg><g><a xlink:href="#!/view1"><circle r="50"></circle></a></g></svg>';
+ var element = $compile(template)($rootScope);
+
+ $rootElement.append(element);
+ var av1 = $rootElement.find('a').eq(0);
+ expect(function() {
+ browserTrigger(av1, 'click');
+ }).not.toThrow();
+ });
+ });
});