accname
accname copied to clipboard
Clarification of 2F for descendants of label with concrete role
The "is a descendant of a native host language text alternative element" in
Otherwise, if the current node's role allows name from content, or if the current node is referenced by aria-labelledby, aria-describedby, or is a native host language text alternative element (e.g. label in HTML), or is a descendant of a native host language text alternative element
-- https://w3c.github.io/accname/#step2F
seems to be ignored by implementors so far (web-platform-tests and NVDA).
Given
<label for="test">
Flash
<span role="menu">
<span role="menuitem">1</span>
</span>
times
</label>
<input id="test" type="text" />
the accessible name of #test is expected to equal Flash times according to several web-platform-tests.
As I see it the algorithm follows these steps:
- set root node to
#test - 2D applies: set current node to
label[for="test"] - 2F applies: children are #Text,
span[role="menu"], #Text - set current node to #Text
- 2G applies: return
Flash - set current node to
span[role="menu"] - 2F applies (element is "descendant of a native host language text alternative element"): children are
span[role="menuitem"] - set current node to
span[role="menuitem"] - 2F applies (allows name from content): children are #Text
- set current node to #Text
- 2G applies: return
1
Now the accumulated text is already Flash 1 and can no longer match Flash times.
Does "allows name from content" include that having a role implies allows name from content? e.g. !role && isDescendantOfTextAlternativeElement(role) || allowsNameFromContent(role)? This would allow e.g. nested <span /> but disallow elements with concrete roles that don't allow name from content and match the web-platform-tests.
If I understand it correctly, role=menu does not meet the condition 2F, but the 2E before it ("control embedded within the label"). Since the control "menu" is not one of these elements from 2E (textbox, button, combobox, listbox, range), the content of the control is ignored. 2F can only apply if it is not a "control embedded within the label".
If my understanding is correct, then the specification lacks a definition of "control" (to make it clear which elements are considered to be control, but whose contents are ignored if they are inside a label)
@JAWS-test So you're saying 2E needs a section explaining
- what is a "control"
- what happens with elements that are not explicitly listed in that step (i.e. which elements to ignore when reaching 2E)
Does this summarize your comment?
- Yes
- That would be good, but is not absolutely necessary
First, however, others would have to say whether my interpretation is correct at all.