accname icon indicating copy to clipboard operation
accname copied to clipboard

accname-aam: step 2E, rule for button can cause infinite loop

Open jnurthen opened this issue 7 years ago • 2 comments

From @cyns on April 29, 2016 19:52

We should remove the special case for button in step 2E because it can cause an infinite loop.

Consider the following markup:

<a href="javascript:void(0)" aria-role="button" aria-labelledby="myLabel" id="foo">Products</a>
<div id="myLabel" role="button">Content</div>

By following the algorithm as described in http://www.w3.org/TR/accname-aam-1.1/, name calculation ends up in an infinite loop when calculating the name of the tag.

A. (Step 1) - start with the empty string B. (Step 2A) - Element is not hidden, so proceed B. (Step 2B) - There is an aria-labelledby tag, so compute the Text Alternative of what aria-labelledby references (in this case, the div with role button) Now compute the Text Alternative for "myLabel" and use that as the tag's name. C. (Step 1') Start with the empty string D. (Step 2A') Not hidden, so proceed D. (Step 2B') Since I'm already part of an aria-labelledby traversal, skip this step E. (Step 2C') No aria-label, so skip this step as well F. (Step 2D') No native markup representation, so skip this step G. (Step 2E') - We are "within the label of another widget", and Role is button, so "return the text alternative of the button." - that is what is currently being calculated, so this step is redundant. If we were to start over here on Text Alternative, we'd never escape the loop. The correct behavior is simply to proceed with the Text Alternative that we're in the process of calculating. So the button role just needs to be removed from the list of special cases here.

Copied from original issue: w3c/aria#357

jnurthen avatar May 21 '18 23:05 jnurthen

How I understood this is that you are then computing the text alternative of the button without being in the context of a label of another element. So while I would agree that removing the special case is a good idea (simply because it removes a special case) I wouldn't agree that this causes an infinite loop.

eps1lon avatar Oct 29 '19 09:10 eps1lon

If I understand it correctly, 2E doesn't cause a infinite loop, but on the contrary: it is prevented:

<input value=1 id=1 aria-labelledby=2>
<input value=2 id=2 aria-labelledby=1>

Without the rules against infinite loop, a circular label without end would appear here. But with step B ("and the current node is not already part of an aria-labelledby traversal") and 2E it is clear that not the label of the input field serves as label of the other input field, but its value.

I think the issue can be closed.

JAWS-test avatar Oct 30 '19 13:10 JAWS-test