Re: [w3ctag/design-reviews] Reference Target (Issue #961)

One potential issue I can see with the non-`id` approach is that it makes changing the active descendant in a combobox two steps instead of one.

For example, [in the current proposal](https://github.com/WICG/webcomponents/blob/gh-pages/proposals/reference-target-explainer.md#-phase-2-shadowroot-referencetargetmap-attribute) (omitting some details for brevity):

```html
<input role="combobox" aria-activedescendant="listbox">
<fancy-listbox id="listbox">
  <template shadowrootmode="open" shadowrootreferencetargetmap="aria-activedescendant: one">
    <div role="listbox">
      <div id="one" role="option">one</div>
      <div id="two" role="option">two</div>
    </div>
  </template>
</fancy-listbox>
```

To update the active descendant from `one` to `two` is just a matter of updating the `shadowrootreferencetargetmap` (or IDL equivalent) to point at `two` instead of `one`. This is similar to what you might do without shadow DOM – update `aria-activedescendant` to point to a different ID.

Whereas with the `referenceTargetForAttributes` counter-proposal:

```html
<input role="combobox" aria-activedescendant="listbox">
<fancy-listbox id="listbox">
  <template shadowrootmode="open">
    <div role="listbox">
      <div role="option" referenceTargetForAttributes="aria-activedescendant">one</div>
      <div role="option">two</div>
    </div>
  </template>
</fancy-listbox>
```

Now the update would require 2 operations: 1) removing `referenceTargetForAttributes` from the first list option and 2) adding it to the second.

IMO this isn't a deal-breaker, but given that the first proposal is fewer operations and closer to the non-shadow DOM equivalent, the first would be my preference.

(BTW this combobox likely requires `shadowrootreferencetargetmap` rather than simply `shadowrootreferencetarget` because you'd likely also need an `aria-controls` pointing at the listbox.)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/961#issuecomment-2449079332
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/961/2449079332@github.com>

Received on Thursday, 31 October 2024 06:19:41 UTC