dom-accessibility-api
dom-accessibility-api copied to clipboard
`computeAccessibleName` doesn't extract repeated text content from aria-labelledby
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)
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?
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
Let me check again if I misinterpreted something or if this should be brought up with spec authors or implementers
Related:
- https://github.com/w3c/accname/issues/33
- https://github.com/w3c/accname/issues/38