dom-accessibility-api icon indicating copy to clipboard operation
dom-accessibility-api copied to clipboard

`computeAccessibleName` doesn't extract repeated text content from aria-labelledby

Open VinceMalone opened this issue 2 years ago • 4 comments

problem

given the following HTML:

<p id="paragraph">
  hello
  <span id="world">world</span>
</p>

<button aria-labelledby="paragraph world">…</button>

I would expect the computed name of the button element to be "hello world world", but computeAccessibleName(button) returns "hello world".

🔗 example test (click "Tests" tab in right panel)

VinceMalone avatar Mar 11 '22 17:03 VinceMalone

Nodes can only be considered once by spec (i.e. according to ACCNAME). So if we compute the reference #paragraph we get "hello world". But that already includes #world so we can't consider it twice.

The reason for that is that this specification avoids infinite loops.

Source:

Important: Each node in the subtree is consulted only once. If text has been collected from a descendant, but is referenced by another IDREF in some descendant node, then that second, or subsequent, reference is not followed. This is done to avoid infinite loops.

-- https://www.w3.org/TR/2019/WD-accname-1.2-20190711/

Does that make sense?

eps1lon avatar Mar 11 '22 17:03 eps1lon

I see; I didn't quite know where to look for that information, but I suspected that might be the case. my only concern is that, while that may be defined in the spec, if you test the aforementioned code with most screen readers today, you get the result I was expecting 😕

I tested with:

  • VoiceOver — macOS 12
  • Narrator — Windows 10
  • NVDA — Windows 10
  • TalkBack — Android 11
  • VoiceOver — iOS 15

VinceMalone avatar Mar 11 '22 17:03 VinceMalone

Let me check again if I misinterpreted something or if this should be brought up with spec authors or implementers

eps1lon avatar Mar 11 '22 17:03 eps1lon

Related:

  • https://github.com/w3c/accname/issues/33
  • https://github.com/w3c/accname/issues/38

jlp-craigmorten avatar Jun 04 '23 10:06 jlp-craigmorten