Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
jribbens opened this issue Jan 23, 2025 · 2 comments
Open
1 task done

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

jribbens opened this issue Jan 23, 2025 · 2 comments
Labels
ungroomed Ticket needs a maintainer to prioritize and label

Comments

@jribbens
Copy link

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.

@jribbens jribbens added the ungroomed Ticket needs a maintainer to prioritize and label label Jan 23, 2025
@dylanb
Copy link
Contributor

dylanb commented Jan 23, 2025

@jribbens what is the CSS for the visually-hidden class in both cases?

@jribbens
Copy link
Author

It's on the example page I linked - it's the standard Bootstrap CSS for the class of that name, so occurs in the wild a great deal:

.visually-hidden {
  position: absolute !important;
  width: 1px!important;
  height: 1px!important;
  padding: 0!important;
  margin: -1px!important;
  overflow: hidden!important;
  clip: rect(0,0,0,0)!important;
  white-space: nowrap!important;
  border: 0!important;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ungroomed Ticket needs a maintainer to prioritize and label
Projects
None yet
Development

No branches or pull requests

2 participants