Description
A recent ACT update added test case e9bbdbec137223e2973c6d2896050770c84c26e5
(Failure Example 4) to proposed ACT rule Visible label is part of accessible name (2ee8b8)
. axe-core currently passes this example where the updated ACT rule expects it to fail:
<a href="#" aria-label="non-standard">nonstandard</a>
This happens because axe-core is much more forgiving about punctuation than the ACT rule. The ACT rule's expectation wording is:
For each target element, all text nodes in the visible text content match characters and are contained within the accessible name of this target element, except for characters in the text nodes used to express non-text content. Leading and trailing whitespace and difference in case sensitivity should be ignored.
The critical difference is in the interpretation of the "except for characters in the text nodes used to express non-text content" clause. label-content-name-mismatch
current removes all punctuation from both label and content before performing its comparison, presuming that punctuation always qualifies as "non-text content", but this isn't accurate in the case where punctuation creates a meaningful difference in language (eg, "government monitoring program" vs "government-monitoring program").
We do want to keep removing punctuation in some circumstances; for example, the 2.5.3 understanding doc's section on Punctation and capitalization clarifies that "First Name" is an acceptable label for a form field with visual content "First Name:", and that "Next" is an acceptable label for a button with visual content "Next...". Maybe we should strip punctuation only at the beginning and end of strings, instead of throughout?
This issue is linked to a skipTests
entry in test/act-rules/visible-label-in-accessible-name-2ee8b8.spec.js
.