-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How should various document internal references work when SVG is being used in shadow DOM #179
Comments
@smaug---- , if you have a change, could you elaborate this issue? |
I think this is similar to the fragment identifier issue and we should resolve it in the same way. E.g., |
I see. I think we can agree that it should not cross the shadow boundary. |
So stuff like
won't be possible in shadow DOM. Doesn't that make it rather hard to use any real world SVG within Shadow DOM? (perhaps that is ok?) But yes, I guess that is the same as filter: url(#element-id) issue. |
As long as the SVG is inside the shadow tree, it will work, no? |
It does? Then I've missed some spec change which makes that fragment identifier to work. |
Perhaps the language in SVG assumes a document tree at the moment, but it seems reasonable for that to work in the same way that |
Sure. But need to make sure the specs actually end up defining that. |
Ah, I asked about this here: http://www.w3.org/mid/89c91562-7e1b-42f3-6cfa-2e651757f32b@jwatt.org Good to see this has already been discussed. |
I assume that is the same issue as inline <!DOCTYPE html>
<html>
<head>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink">
<symbol id="icon-cog">
<path d="...."/>
</symbol>
<symbol id="icon-close">
<path d="...."/>
</symbol>
</svg>
</head>
<body>
<custom-element>
#shadow-root
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="#icon-cog"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="#icon-close"/>
</svg>
/shadow-root
</custom-element>
</body>
</html> I would say here that the fragment identifier should cross shadow boundary in this case. The workaround to this if not crossing is to reference an external file like so: <!DOCTYPE html>
<html>
<head>
</head>
<body>
<custom-element>
#shadow-root
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"
onclick="root.toggleMenu( settingsMenu )">
<use xlink:href="icons/library.svg#icon-cog"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"
onclick="window.close()">
<use xlink:href="icons/library.svg#icon-close"/>
</svg>
/shadow-root
</custom-element>
</body>
</html> But if you need to change the I assume fragment identifier issue have to resolve the same way for all use cases, so maybe it's not possible to I don't have recommendation here, I'm just pointing out a use case to take care of for this issue ! |
SVG use element is indeed an interesting use case to consider. We probably need to come up with a new syntax / feature to make it work across shadow boundaries. |
With the advent of the implementations of Shadow DOM, this needs to be adressed: Devs who are trying to use the Shadow DOM cannot use non-trivial SVG at the same time, because Safari does not implement (or probably rather "actively disables") SVG Use elements inside shadow trees: https://bugs.webkit.org/show_bug.cgi?id=174977 They refer to this bug and say that it is because of the missing spec that they cannot implement svg use elements inside shadow doms. I disagree, though and agree with @annevk that at least as long as the SVG in question is fully contained inside a shadow tree, it should work just like it would work at the root document level. Could you please reconsider the priority of this bug? Because without a resolution web developers will either have to make the choice between not using Shadow Dom, not using SVG, and not using Safari. I am sure they will decide not to use Shadow Dom, which would be a pity. |
I think everyone would agree that this should work. What clarification is required in SVG spec?
This is questionable. I object to it. |
https://drafts.fxtf.org/filter-effects/#FilterProperty seems to define this property (though maybe it's defined elsewhere too?) and it's basically super vague. |
Unfortunately the Safari team disagrees here. Their implementation does not work for the "simple" case and they say it is because of the spec not being clear enough here. |
Since |
Does any browser actually support full URLs there or just local fragment references? I thought it is mostly the latter, but if it isn't this is indeed more complicated. |
Firefox definitely supports referencing a fragment in another file although Safari & Chrome don't support that. |
@rniwa - while I agree that it is not defined how it should work (and I also believe that probably the best solution would be to not make it work at all) to reference a fragment inside another document buried in a shadow dom or inside another shadow tree in the same dom, my concern right now is that the Safari/Webkit team claims that the SVG spec is not even clear enough about local fragments inside the same shadow tree dom. Please correct me (and them) if I'm wrong, but IMHO at least this should work, or shouldn't it: anywhere on the page (be it inside a closed, or open shadow dom tree or at the top-level) this must work:
(slightly stripped down version from here https://www.w3.org/TR/SVG/struct.html#UseElement ) However according to them "because of the unclear spec" this svg does not work inside Safari in a shadow DOM. This makes all of our SVGs break if they are used inside a shadow dom in Safari, and thus all of our customers cannot use shadow dom in their products if they need to target Safari and I would greatly appreciate it if you could somehow make a clear statement that at least this use-case must work according to the spec so that they will adjust their current implementation. Thank you! |
You keep saying that this is a claim but it's not a claim. It's a fact that there is no spec at W3C that either defines or mandates the behavior you're describing. The fact Blink behaves in the way you'd like is almost a coincidence.
I'm not at all certain that everyone would agree to that proposition. |
OK, thanks a lot for the clarification. So I think it should be clearly communicated and stated that SVGs and shadow DOM don't work together nicely if implemented according to the current spec and that devs cannot rely on the implementations that currently do support this "against the spec". Even Anne van Kesteren thought that this feature should work according to the current spec if I interpret this comment correctly: #179 (comment) - without a clear statement how should the majority of "normal devs" understand the current situation? SVG 'use' elements are a very important part for SVGs, at least if you use SVG to programmatically create vector graphics. So if they don't actually work in shadow DOMs that is a huge problem for shadow doms, IMHO: Shadow doms are used for creating and encapsulating complex web components. If those components cannot use sophisticated vector graphics, then this is a blocker for many component developers (like us) and they won't be adopting shadow doms, which would be a pity because they would benefit the most from shadow doms. I understand that it may be difficult to change the spec so that this will work formally, but I think that absolutely needs to be done (and that's basically what this ticket is all about). It's almost as if you had decided not to support a rather basic feature like background colors or margins in shadow doms - people will choose to have background colors and margins over using shadow doms if that is the only way they can get background colors and margins to work. I say that if you want shadow dom to become widely adopted, this SVG use-case absolutely needs to be supported, whatever it takes. |
The problem is that SVG uses URLs for both local and non-local references and most browsers only implement the local part. In CSS at least there was a plan to make these local reference special (URLs starting with #) and that probably applies here too given it's a CSS property. @tabatkins? It seems that hasn't really propagated to all specifications yet. |
Oh gosh, I didn't even think about the effect of scoped-IDs on frag-references. I guess it's the same issue as dealing with So yeah, frag urls are special in It's a small hop from there to specifying that, within a shadow tree, they are scoped to referring only to the IDs defined in the shadow. I'm fine with that - is that how we want to proceed? If so, I can bring it to the CSSWG and get it approved. |
@tabatkins yeah, that's basically the proposal. Search within your tree for IDs not within your document. |
I don't think that solves SVG |
:-( Better "ugly and working" than "nice and unusable", though, IMHO. |
Here are the current blockers for this issue: |
I am working on a library of UI components for Angular. I use SVG icons declared on top of the page and referenced with use tag. When I tried to convert my library components to Web Components so no Angular is required I was very sad to find that it doesn't work with Shadow DOM. I understand the concerns, but practicality of this approach is just huge. This thought first mentioned way above by @devingfx :
I really hope this would be resolved. |
@rniwa Was there any discussion around behavior for fragment-only url values for anchor/area href attributes? Your comment seems to imply that these could potentially reference elements outside the shadow and I'm curious if this is the case. |
I don't think anyone thought allowing references to a node outside one's shadow tree was a good idea at least during F2F. |
Don't know whether this is the right place to discuss this, but I think it is at least related - sorry for the noise if this is the wrong place: The I would hope that it works like this: at least if the canvas which provided the canvascontext lives in the same shadow DOM as the SVG filter, a relative url should resolve to the filter in the SVG. If the canvas image is currently not in the DOM, I don't see how this could ever resolve to a filter declared in a shadow tree, however. TBH I haven't tested this, myself; it's implemented in FF and Chrome, only, so far, and I don't know whether there is a spec for this with respect to shadow dom. I just played with that feature and loved it when it works and I was hoping that it would still work inside custom components. |
@yGuy thanks for spotting that! Could you please file an issue against whatwg/html? It should be specified right there and currently has a rather vague "same document" sentence that is broken. I agree with you on how this should work. If you're willing to write tests per https://github.com/web-platform-tests/wpt for this that might help ensure browsers get it correct sooner. I'd be happy to help guide you in that. |
@rniwa maybe there could be some specific syntax allowing shadow DOM items to reach out to search segments outside their shadow tree? Seems to me that reaching out shouldn't be that bad, at least as explicitly specified intention, it's not like reaching in to mess with isolated component. |
Perhaps. The trick is to come up with a proposal that's backwards compatible, which might be tricky. |
element.attachShadow({
mode: 'open',
delegatesFocus: true,
xlink: 'parent',
cssPassThrough: true
}) ;) I donno how to write specs ... [Edit]: Maybe just ShadowRootInit needs to be agmented...
|
Please file a new issue to discuss that kind of proposal. This issue is used as a meta bug for tracking issues pertaining internal referencing used in SVG. |
…trees. r=smaug Other UAs allow this, and it seems in the general consensus of WICG/webcomponents#179. This matches WebKit's behavior. Blink, for some reason shows red on the test-case, probably because they're not doing quite this, but they manage to render masks inside the display: none symbol element or such. Differential Revision: https://phabricator.services.mozilla.com/D72610
…trees. r=smaug Other UAs allow this, and it seems in the general consensus of WICG/webcomponents#179. This matches WebKit's behavior. Blink, for some reason shows red on the test-case, probably because they're not doing quite this, but they manage to render masks inside the display: none symbol element or such. Differential Revision: https://phabricator.services.mozilla.com/D72610
…trees. r=smaug Other UAs allow this, and it seems in the general consensus of WICG/webcomponents#179. This matches WebKit's behavior. Blink, for some reason shows red on the test-case, probably because they're not doing quite this, but they manage to render masks inside the display: none symbol element or such. Differential Revision: https://phabricator.services.mozilla.com/D72610 UltraBlame original commit: 8efff752175e177108adceddb73a60f98f8cdd27
…trees. r=smaug Other UAs allow this, and it seems in the general consensus of WICG/webcomponents#179. This matches WebKit's behavior. Blink, for some reason shows red on the test-case, probably because they're not doing quite this, but they manage to render masks inside the display: none symbol element or such. Differential Revision: https://phabricator.services.mozilla.com/D72610 UltraBlame original commit: 8efff752175e177108adceddb73a60f98f8cdd27
…trees. r=smaug Other UAs allow this, and it seems in the general consensus of WICG/webcomponents#179. This matches WebKit's behavior. Blink, for some reason shows red on the test-case, probably because they're not doing quite this, but they manage to render masks inside the display: none symbol element or such. Differential Revision: https://phabricator.services.mozilla.com/D72610 UltraBlame original commit: 8efff752175e177108adceddb73a60f98f8cdd27
From #179 (comment), this issue really contains three sub-issues:
Of those, the first one seems to be resolved, down to actually modifying the spec. I.e. browsers agree on behavior - SVG elements can reference other elements within the same shadow tree. Is that correct? The second one is about expanding fragment references to be able to cross shadow boundaries. I'm not sure there's appetite for that change or not, but there has been very little discussion on that issue. The last one really isn't about SVG specifically, but is about other global name defining things (e.g. Is the above an accurate summary of the state of this issue? If so, I would propose closing this issue, since the sub-parts are well-tracked in the linked issues. |
That seems correct to me, thanks for summarizing. @rniwa? |
Yeah, I think that's accurate although we need some way to track all those CSS issues in this issue tracker somehow since it doesn't seem like any progress has been made in terms of spec work there. |
Alright, happy to keep this open with that understanding. If someone wanted to they could also create a new issue containing those pointers and we could close this. Either way. |
Yeah, we really need a better way of tracking all these issues scattered across many different WG's issue trackers. Maybe we can have a wiki page with a list of issues instead? We won't be able to cross-reference though so it has some downsides compared to the status quo. |
Closing this in favor of #772 |
Title: [Shadow] How should various document internal references work when SVG is being used in shadow DOM (bugzilla: 27380)
Migrated from: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27380
comment: 0
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27380#c0
Olli Pettay wrote on 2014-11-20 12:37:34 +0000.
The text was updated successfully, but these errors were encountered: