w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.5k stars 667 forks source link

Clarify how fragment URLs are resolved within shadow trees #2715

Open AmeliaBR opened 6 years ago

AmeliaBR commented 6 years ago

See https://github.com/w3c/webcomponents/issues/179, particularly https://github.com/w3c/webcomponents/issues/179#issuecomment-321324082, where @tabatkins says:

frag urls are special in url() - https://drafts.csswg.org/css-values/#local-urls. They stay fragments and are always treated as "local" to the referencing document no matter what the base url is.

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.

I think it would be suboptimal if references were scoped so that they only refer to other shadow IDs. It would force a lot of unnecessary duplication of SVG markup if you can't reference markup in the parent tree, and would require the SVG spec to define some extra magic to explain how use element trees work.

But we do want references that are internal within the shadow tree to work, so that a complete SVG inlined within a shadow tree doesn't fall apart. I suggested a recursive search from the local tree working out.

That said, I also suggested that it would be best if this reference-matching algorithm could be defined in a consistent way for all applications. So this is more of a tracking bug, until a decision is made for the web components issue.

Related issue for discussion non-CSS cross references in SVG: https://github.com/w3c/svgwg/issues/466

rniwa commented 6 years ago

TPAC F2F WebPlat note: We'll discuss this along with https://github.com/w3c/webcomponents/issues/179