Re: [csswg-drafts] [css-values] Clarify fragment URLs resolve against the current tree, not document tree (#3320)

Okay, new text committed as a result of the WG discussion - fragment-only URLs are now explicitly treated as tree-scoped references, with the set of IDs in the tree as the associated tree-scoped names.

This implies that `x-foo::part(foo) { mask: url(#foo); }` will resolve to the element with id=foo in the light DOM, regardless of what IDs are used inside the shadow, while `<div part=foo style="mask: url(#foo)">` inside the shadow will resolve to the element with id=foo in the shadow. (But if there is no such element, it'll walk up to the light and look for the ID there.)

For the question of what to do with Media Fragments and similar non-ID fragment syntaxes, I'm currently just treating them identically to anything else - I try to find an element with a matching ID and if it fails (as it almost certainly will) it fails as normal, and is treated the same as if `#foo` wasn't in the document.

This probably needs some more work to make this good. In particular, this doesn't work properly with [fragment directives](https://wicg.github.io/scroll-to-text-fragment/#processing-the-fragment-directive) - `url(#foo:~:text=foo)` will search for an element with `id="foo:~:text=foo"`, rather than stripping the directive. I've opened an issue (<https://github.com/WICG/scroll-to-text-fragment/issues/198>) to get an algo exposed for doing that easily.

Anything else the WG thinks is still wrong, or needs to be added?

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3320#issuecomment-1334499499 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 1 December 2022 21:59:59 UTC