w3c / accname

Accessible Name and Description Computation
https://w3c.github.io/accname/
62 stars 22 forks source link

When does flattening of the name occurs? #63

Open Jym77 opened 5 years ago

Jym77 commented 5 years ago

The description of the algorithm states that the result is a flat string (replacing linebreak with spaces and collapsing adjacent spaces). However, there is no point in the algorithm which specifies that this flattening occurs.

Notably, Step 2C returns the value of aria-label without flattening (nor trimming); and Step 2G return the textual content of text node without flattening nor trimming. In the end (no step number), the result of these steps is appended to the total accumulated text without flattening nor trimming, and this total accumulated text is used as accessible name without flattening or trimming.

accdc commented 5 years ago

I agree this isn't as clear as it should be. I hope to address this when I work on the AccName simplification project.

At present though, this is indicated at the beginning of the section at https://www.w3.org/TR/accname-1.1/#mapping_additional_nd

"The starting point of the name and description computation is a DOM element. The output is a flat, unstructured string that can be as simple as a single word, or a string of space separated tokens."

So, this needs to be applied just after all of the nodes are processed using the recursive algorithm, on the total result string comprising either the name or description property.

"Flat string A string of characters where all carriage returns, newlines, tabs, and form-feeds are replaced with a single space, and multiple spaces are reduced to a single space. The string contains only character data; it does not contain any markup." https://www.w3.org/TR/accname-1.1/#terminology

Jym77 commented 5 years ago

Yes, this is not too much of a problem given that flattening is idempotent, so doing it once at the end is enough, and doing it at each step is not useful. Step 2D does explicitly mention flattening the intermediate result, making this even more confusing 😕

MelSumner commented 3 months ago

I think that this issue has been resolved:

AriaLabel: Otherwise, if the current node has an aria-label attribute whose value is not undefined, not the empty string, nor, when trimmed of whitespace, is not the empty string: