Skip to content

label-content-name-mismatch wrongly includes invisible text #4678

Open
@jribbens

Description

@jribbens

Product

axe-core

Product Version

4.10.2

Latest Version

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

Issue Description

Expectation

Given the following HTML code, axe should not report an label-content-name-mismatch violation:

<a aria-label="deque are great" href="https://www.deque.com/">
  deque <span class="visually-hidden">labs</span> are great
</a>

Given the following HTML code, axe should report an label-content-name-mismatch violation:

<a href="https://www.deque.com/">
  deque <span class="visually-hidden">labs</span> are great
</a>

Actual

It emits a diagnostic on the code which is correct, and does not emit one on the code which is incorrect.

How to Reproduce

See above. Or also: https://unequivocal.eu/label-content-name-mismatch.html

Additional context

The rule is supposed to be comparing the accessible name with the visible text of the item, but it seems to be comparing all of the text. Also it only checks elements with an aria-label or aria-labelledby, which is incorrect as the rule can fail even without an ARIA label (i.e. the second example above). See https://www.w3.org/WAI/WCAG21/Techniques/failures/F96 for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixBug fixesrulesIssue or false result from an axe-core rule

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions