Skip to content

Misleading issue text when a section element has an aria-labelledby attribute that references an empty element #4140

Open
@mfairchild365

Description

@mfairchild365

Product

axe-core

Product Version

4.7.2

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

Given this HTML

<section aria-labelledby="heading2">
  <h3 id="heading2"></h3>
  <p>content in section</p>
</section>

axe returns a needs-review issue "Elements must only use allowed ARIA attributes." That issue states:

This potential issue needs your review...
aria-labelledby attribute is not well supported on a section with no valid role attribute.

And

To solve this problem, you need to fix the following:
aria-labelledby attribute is not well supported on a section with no valid role attribute.

However, this HTML does not return any issues:

<section aria-labelledby="heading1">
  <h3 id="heading1">Test heading</h3>
  <p>content in section</p>
</section>

The only difference is that the second example's aria-labelledby reference has text content, while the first example does not. Thus, the issue appears to have more to do with the fact that the element referenced by aria-labelledby does not have any text. Something that is not obvious from the text of the issue that was raised.

Example can be found here: https://codepen.io/mfairchild365/pen/KKbdQov

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixBug fixesrule metadataIssues in the rule metadata code (lib/rules)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions