Re: [csswg-drafts] [css-anchor-position-1] Allow anchor references to match names in outer tree scopes (#9408)

This issue seems so much like [accessibility with shadow roots,](https://alice.pages.igalia.com/blog/how-shadow-dom-and-accessibility-are-in-conflict/) if it's not included by default it could be years before it's possible to get enough weight behind a productive solution. We should take care not to ship something to the web platform that doesn't support all of the web platform!

Luckily there is some prior art to lean on here.

Take for instance [`arialabelledbyelements`](https://w3c.github.io/aria/#dom-ariamixin-arialabelledbyelements) a DOM property that allows an element to be labeled by an array of element references that are in the same shadow tree or an ancestor tree. We may be waiting on long-rumored Blink and Mozilla implementations of this, but they are getting close and will do some great things to accessibility with shadow roots. Can we find a reciprocal version of this for anchor references?

Some things that I could certainly see as important to work out in this context:

**Unmanaged sharing**
I'm not quite sure how this could be possible but for anyone interested in going down this path.
- if there is some sort of sharing between trees, and it is not managed in some way, which tree "wins"? e.g. if there is an `anchor-name: --anchor-1` in the local DOM tree and an `anchor-name: --anchor-1` in the parent DOM tree, which gets leveraged?
- similar if this sharing is non-managed, would it be expected that CSS would need to walk up ALL DOM trees to _possibly_ resolve an anchor? 

I'm not sure there are good or performance answers to these questions but they should be discussed well before something in this realm hits "stable".

**Managed sharing**
What would this look like? The main goal would seem to prevent anchor name collision, but this could also manage the distance to which a browser would need to go to resolve an anchor name.
- is a CSS custom property enough to pass an anchor name across multiple shadow trees? [See example](https://github.com/w3c/csswg-drafts/issues/9408#issuecomment-1734672692).
- could an element with a shadow root define how many trees away an anchor name could be searched for?
- do we need something like downward facing [`exportparts`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts) to make them available to child trees?
- [the reference target proposal](https://github.com/WICG/aom/blob/gh-pages/reference-target-explainer.md) may provide prior art here, as well

I look forward to seeing this make its way into the larger conversation before any "stable" API is marketed to the larger web development community as ready to go!


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


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

Received on Saturday, 11 May 2024 11:47:49 UTC