Skip to content

Commit aec6f37

Browse files
committed
Allow unmatched elements for 4.1.2 which are role='button' to use aria labels to pass as valid names for an accessibility API. This will trigger on any element using that role. This resolves #160.
1 parent 5388657 commit aec6f37

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Standards/WCAG2AAA/Sniffs/Principle4/Guideline4_1/4_1_2.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = {
205205
var matchingRequiredNames = requiredNames[nodeName];
206206
var requiredValue = requiredValues[nodeName];
207207

208-
// Any element that doesn't have specific handling must have content.
208+
// Any element that doesn't have specific handling must have content or aria labels.
209209
if (!matchingRequiredNames && nodeName !== 'input_hidden') {
210-
matchingRequiredNames = ['_content'];
210+
matchingRequiredNames = ['_content', '@aria-label', '@aria-labelledby'];
211211
}
212212

213213
// Check all possible combinations of names to ensure that one exists.
@@ -230,7 +230,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = {
230230
} else if (requiredName.charAt(0) === '@') {
231231
// Attribute.
232232
requiredName = requiredName.substr(1, requiredName.length);
233-
234233
if ((requiredName === 'aria-label' || requiredName === 'aria-labelledby') && HTMLCS.util.hasValidAriaLabel(element)) {
235234
break;
236235
}

Tests/WCAG2/4_1_2_Aria_Labels.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
Assert: No Error *.H53.ARIA6 on #objectLabelledBy
1414
Assert: No Error *.H53.ARIA6 on #objectLabel
1515
Assert: No Error *.H91.A.NoContent on #hyperlinkLabel
16+
Assert: Error *.H91.* on #buttonRoleFail
17+
Assert: No Error *.H91.Name on #buttonRoleSuccess
1618
-->
1719
</head>
1820
<body>
@@ -45,6 +47,9 @@
4547

4648
<a id="hyperlinkLabel" href="http://www.squiz.net" aria-label="Label as valid content"></a>
4749

50+
<div role="button" id="buttonRoleFail"></div>
51+
<div role="button" id="buttonRoleSuccess" title="Toggle time list" aria-label="Toggle Time List" aria-controls="myid"></div>
52+
4853
</form>
4954
</body>
5055
</html>

0 commit comments

Comments
 (0)