-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngInclude doesn't work for SVG in Safari or Firefox (5263) #7538
Comments
Also in chrome, it outputs a lot of errors in the console, as the interpolation symbols are not valid for svg attributes. However, I don't know a way of preventing those errors. They even show up when putting those svg elements inside of a template tag. |
@caitp and @IgorMinar FYI. I think this is legit, although I am not sure how well we would like to support interpolation in svg (e.g. using |
Ignore the interpolation errors; the original plunk author should've used "ng-attr-[attribute]" (e.g.: ng-attr-dx) for those. Here's one with the proper attributes: http://plnkr.co/edit/6L7cv6sjSaROJsEx0qAT?p=preview |
it's true though, it still doesn't work. I'm looking into it =) |
I'm not totally sure exactly what is happening here, but the element which is receiving the interpolated attribute values, seems to be HTMLUnknownElement in Gecko (and possibly Safari too, but the devtools in safari keep crashing on me so it's hard to verify =() --- so, these should still be added to the DOM, but that doesn't seem to be happening, and I haven't sorted that out yet. I think turning this into a failing unit test would make this easier to sort out, but the question is, what's the priority like on this --- because there are some other issues I'd like to take care of this week. Thoughts? |
This may be related. see http://embed.plnkr.co/FMgx03i4Vkc6rDeAeFaT/preview debug shows the element as I have a project with a fair bit of this type of code and would love a fix or at least to understand what is going on. My work-around is to only set styles on the parent elements but there are some circumstances where this is difficult. |
That class bug isn't in 1.2.16; you should consider upgrading |
the reason for this not working in FF/Safari as opposed to Chrome is that the behavior of innerHTML in Chrome is different from that of FF/Safari. (we use innerHTML in ngInclude) In chrome when you innerHTML into an svg element, the inlined DOM will be created within the svg namespace (check namespaceURI), however in firefox it is created in html/xhtml namespace. @caitp is checking which browser is doing the wrong thing here. |
asking PDR about this, but the reproduction in angular was a bit too complicated for him to assess. I've put together a vanilla reproduction of this, but it's not quite a faithful reproduction of what's happening in angular (but interestingly, does sort of reproduce the issue!) Igor can you take a look at it and see if that looks sort of faithful to you? http://jsfiddle.net/j4pWZ/ / http://jsfiddle.net/82f6S/ (with logging) |
It looks like it is the same issue to me, HTMLUnknownElement instead of SVGGElement |
Based on http://jsfiddle.net/3LktM/, setting innerHTML in non-blink browsers seems to be the main culprit, not cloneNode |
Correct. As I mentioned before it's innerHTML that is causing these issues I haven't looked into cloneNode myself but I heard that it was problematic
|
Hi all, Using Angular 1.3-rc.0 and svg directives, ng-include only works in Chrome. Safari and FF are broken. FF reports:
@caitp, as this bug report is related to 1.2.16, should I create a new issue? Thanks in advance |
well ngInclude doesn't do our templateNamespace hackery... to support ngIncluding SVG files we'd probably need to add another attribute to tell ngInclude how it should wrap the template, or something. @IgorMinar what do you think? We could also have a quick and dirty ngIncludeSvg or something, heh. |
As |
It doesn't really transclude content --- it transcludes the root node, but it just raw $compiles() the template content, which is the problem here --- we can detect that the root is an SVG node, but we can't detect that any of the children loaded from the template are SVG nodes this way |
Yes, and we need some way know whether to use the special way of creating the svg nodes. You proposed an additional attribute, but I say we should already know this information when ngInclude calls |
Or better: could you do it? |
I'll work on something in a moment |
I have a fix for this, uploading in a sec |
It is now possible for ngInclude to correctly load SVG content in non-blink browsers, which do not sort out the namespace when parsing HTML. Closes angular#7538
It is now possible for ngInclude to correctly load SVG content in non-blink browsers, which do not sort out the namespace when parsing HTML. Closes angular#7538
It is now possible for ngInclude to correctly load SVG content in non-blink browsers, which do not sort out the namespace when parsing HTML. Closes angular#7538
It is now possible for ngInclude to correctly load SVG content in non-blink browsers, which do not sort out the namespace when parsing HTML. Closes angular#7538
+1! |
"Invalid" bug #5263 is still a problem (1.2.16).
The example plunkr at http://plnkr.co/edit/Igvyeb1g4sWHoeOgAHTz?p=preview only works in Chrome.
The text was updated successfully, but these errors were encountered: