-
Notifications
You must be signed in to change notification settings - Fork 59
Description
In the current proposed implementation of ARIA element reflection in WebKit, as well as the relevant PR on the spec (whatwg/html#3917) and this WPT test, element reflection only works for elements whose shadow roots are either the same, or in a descendant/ancestor relationship:
If
element's explicitly setattr-element is a descendant of any ofelement's shadow-including ancestors, then returnelement's explicitly set attr-element. Otherwise, return null.
As discussed previously, though (whatwg/html#4925 (comment)), there are use cases where the elements' shadow roots may have sibling (or cousin, aunt/niece, etc.) relationships.
For instance, following the ARIA 1.1 Combobox with Listbox Popup example, an implementation with web components might look like:
<fancy-input>
#shadow-root
<input type="text">
</fancy-input>
<fancy-listbox>
#shadow-root
<ul role="listbox">
<fancy-option>
#shadow-root
<li role="option">List item</li>
</fancy-option>
</ul>
</fancy-listbox>In this case, the web author may want to set the <li> to be the ariaActiveDescendant of the <input>. However, their shadow roots are not in a descendant-ancestor relationship, so attempting to set the ariaActiveDescendant would be a no-op.
With some tinkering of the DOM hierarchy, it's possible to work around this restriction:
<fancy-input>
#shadow-root
<input type="text">
<fancy-listbox>
#shadow-root
<ul role="listbox">
<fancy-option>
#shadow-root
<li role="option">List item</li> <!-- shadow descendant of the <input> -->
</fancy-option>
</ul>
</fancy-listbox>
</fancy-input>However, this requires the <fancy-listbox> to be inside the <fancy-input>'s shadow root, which increases the scope of <fancy-input> beyond just enhancing the <input>.
Another potential alternative is to use cross-root ARIA delegation to have the <input> delegate its aria-activedescendant to the <fancy-input> host, but AFAICT the current version of that spec doesn't handle element ID ref attributes like aria-activedescendant.
If I understand the previous summary (whatwg/html#5401 (comment)), this restriction was put in place to avoid leaking internal component details. If we assume all of the shadow roots are open, though, then I'm not sure that that argument is still as strong. It feels like the restriction makes wiring up relationships across shadow boundaries very tricky, whereas in the light DOM world we don't have any similar restrictions.
Would this group be open to relaxing the restriction on cross-shadow ARIA relationships?
/cc @leobalter @mrego