-
Notifications
You must be signed in to change notification settings - Fork 27.5k
when clicking on SVG diagrams with links I get: TypeError: Object #<SVGAnimatedString> has no method 'indexOf' #5198
Comments
…exOf' when clicking on an SVG diagram with links a minor patch to check a url is a string before attempting to call indexOf() on it to avoid barfing on SVGAnimatedString fixes angular#5198
+1, got this error today myself |
@jstrachan please submit a plunker/jsfiddle or PR with a test. thanks! |
@jstrachan is your pull request still in progress? Would it be too much trouble to put together a plunker demonstrating the issue? |
@jeffbcross phew - managed to recreate it in a plunker basically if you use $location then have an SVG diagram with any elements inside and you click on the SVG diagram it generates the TypeError in the JavaScript console |
@jeffbcross incidentally the HTML is a little bigger than is required ;) e.g. you can ignore the <style> element and the details of the tree; other than just its a shape with an element inside - then its the presence of $location in the controller that causes the bug |
Thanks! I was able to reproduce the issue. I'm a little slammed this week, but hopefully I can take a look at a fix soon (or review a PR if you submit one). |
I think the issue here is the So basically, we get an SVGAnimatedString, which gives us "baseVal" and "animVal", where "baseVal" is the value before applying transformations, and "animVal" is either equal to "baseVal" if not animated, or the current transformed state. I really can't decide if it's more appropriate to use animVal or baseVal there! But I guess it's important to get the proper value out of it. Or maybe just abort if href is an SVGAnimatedString? Anyways, this is kind of painful because the SVGAnimatedString doesn't give us the absolute href as parsed by the browser. Maybe it would be better to just skip handling these SVGAElement links all together. |
Well there's my shot at it, maybe it could/should be handled differently. Let me know |
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
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
pull request on its way...
The text was updated successfully, but these errors were encountered: