Skip to content

How should labeledby calculation handle whitespace-only content? #233

Open
@dandclark

Description

@dandclark

I'm looking at the test case "button's hidden referenced name (visibility:hidden) with hidden aria-labelledby traversal falls back to aria-label" in the WPT accname/name/comp_label.html.

<button aria-labelledby="span4" aria-label="foo" data-expectedlabel="foo" data-testname="button's hidden referenced name (visibility:hidden) with hidden aria-labelledby traversal falls back to aria-label" class="ex">
  <span id="span4">
    <span id="span5" style="visibility:hidden;">label</span>
  </span>
  x
</button>

One problem is that the span4 element ID is duplicated from the previous test; I'm fixing that in web-platform-tests/wpt#45117.

In Chromium, the test still fails because Blink includes the whitespace under span4 as span4's a contribution to the LabeledBy Recursion in step 2B LabeledBy. So we end up using that whitespace as the computed name, instead of falling back to the aria-label, and the test fails.

If I delete the whitespace under span4 then the test passes.

The spec language doesn't say anything here about not counting whitespace:

  • i. Set the accumulated text to the empty string.
  • ii. For each IDREF:
    • a. Set the current node to the node referenced by the IDREF.
    • b. LabelledBy Recursion: Compute the text alternative of the current node beginning with the overall Computation step. Set the result to that text alternative.
    • c. Append a space character and the result to the accumulated text.
  • iii. Return the accumulated text if it is not the empty string ("").

So per the spec, Chromium's behavior seems to be correct and the test incorrect, but I don't think that's the intent. Should the spec have a step to strip whitespace from the accumulated text in step iii before deciding whether not to return it?

Metadata

Metadata

Assignees

Type

No type

Projects

Status

High priority

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions