This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Following hyperlink in svg throws exception. #1420
Comments
I've encountered the same problem while using D3 with angular. |
+1 |
+1, please approve the pull request above, it makes a deal |
+1, would be awesome! |
closing in favor of #5198 |
IgorMinar
pushed a commit
that referenced
this issue
Dec 19, 2013
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
jamesdaily
pushed a commit
to jamesdaily/angular.js
that referenced
this issue
Jan 27, 2014
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 angular#5472 Closes angular#5198 Closes angular#5199 Closes angular#4098 Closes angular#1420
jamesdaily
pushed a commit
to jamesdaily/angular.js
that referenced
this issue
Jan 27, 2014
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 angular#5472 Closes angular#5198 Closes angular#5199 Closes angular#4098 Closes angular#1420
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have posted a query in SO, and hopefully the fix as suggested would help to use svg elements within angular applications.
It has nothing to do with d3, as I made a fiddle with just an svg element to reproduce the issue.
http://jsfiddle.net/DEvDe/1/
http://stackoverflow.com/questions/12588913/svganimatedstring-missing-method-indexof
I am using d3.js together with angularjs. When use hyperlink in svg object(which rendered through angular directive), I am getting this error.
As per the doc here, svgAnimatedString doesn't have any specific method. How can I solve this. Can I inject a method or any other way.
Part of the code below. Thanks you.
svg.selectAll("a.node")
.data(data)
.enter().append("a")
.attr("class", "node")
.attr("xlink:href", "test")
.append("rect")
Proposed solution:
Various libraries have encountered this problem (i.e here). In SVG, when you try to get the href attribute of an anchor it returns an SVGAnimatedString. You get the actual string by using SVGAnimatedString.baseVal. I don't know how you can do this without patching Angular, but this will give you an idea of what is needed:
this.$$rewriteAppUrl = function(absoluteLinkUrl) {
if (absoluteLinkUrl.baseVal != null) {
absoluteLinkUrl = absoluteLinkUrl.baseVal;
}
if(absoluteLinkUrl.indexOf(appBaseUrl) == 0) {
return absoluteLinkUrl;
}
}
The text was updated successfully, but these errors were encountered: