Open
Description
Product
axe-core
Feature Description
Take the following HTML with accessible names defined via aria-label
:
<button aria-label="1: View all">1: View all</button>
<button aria-label="2: View all videos">2: View all</button>
<button aria-label="3: View all of my videos">3: View videos</button>
Variants 1 and 2 pass the "label-content-name-mismatch" rule because it just checks the prefix of the aria-label
against the actual text content of the node. Variant 3 fails the test because all of my
is inserted in the middle of the label, but is clearly a more descriptive label for the given button.
The "label-content-name-mismatch" rule should be more relaxed and just check if all words of the accessible name are in occuring in the same order as in the visible text.
Here a screenshot of a concrete example in Lightouse 11 with axe-core 4.8:

Should pass
<button aria-label="one">one</button>
<button aria-label="one two">one</button>
<button aria-label="one two three">one three</button>
Should fail
<button aria-label="one">two</button>
<button aria-label="three two one">one two three</button>