Skip to content

Commit dec8759

Browse files
committed
Fix for #158 and #159. Object now allows aria-label in lieu of other alternative text methods.
1 parent efbd741 commit dec8759

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_1/1_1_1.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = {
347347
var errors = this.testMediaTextAlternatives(top);
348348

349349
for (var i = 0; i < errors.object.missingBody.length; i++) {
350-
HTMLCS.addMessage(HTMLCS.ERROR, errors.object.missingBody[i], 'Object elements must contain a text alternative after all other alternatives are exhausted.', 'H53');
350+
HTMLCS.addMessage(HTMLCS.ERROR, errors.object.missingBody[i], 'Object elements must contain a text alternative after all other alternatives are exhausted.', 'H53,ARIA6');
351351
}
352352

353353
for (var i = 0; i < errors.object.generalAlt.length; i++) {
354-
HTMLCS.addMessage(HTMLCS.NOTICE, errors.object.generalAlt[i], 'Check that short (and if appropriate, long) text alternatives are available for non-text content that serve the same purpose and present the same information.', 'G94,G92.Object');
354+
HTMLCS.addMessage(HTMLCS.NOTICE, errors.object.generalAlt[i], 'Check that short (and if appropriate, long) text alternatives are available for non-text content that serve the same purpose and present the same information.', 'G94,G92.Object,ARIA6');
355355
}
356356

357357
for (var i = 0; i < errors.applet.missingBody.length; i++) {
@@ -392,11 +392,14 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = {
392392
// If we have an object as our alternative, skip it. Pass the blame onto
393393
// the child.
394394
if (childObject === null) {
395-
var textAlt = HTMLCS.util.getElementTextContent(element, true);
396-
if (textAlt === '') {
397-
errors.object.missingBody.push(element);
395+
if (HTMLCS.util.isStringEmpty(HTMLCS.util.getElementTextContent(element, true)) === true) {
396+
if (HTMLCS.util.hasValidAriaLabel(element) === false) {
397+
errors.object.missingBody.push(element);
398+
}
398399
} else {
399-
errors.object.generalAlt.push(element);
400+
if (HTMLCS.util.hasValidAriaLabel(element) === false) {
401+
errors.object.generalAlt.push(element);
402+
}
400403
}
401404
}//end if
402405
}//end if
@@ -425,6 +428,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = {
425428
hasError = true;
426429
}
427430

431+
// Catch anything with a valid aria label.
432+
if (HTMLCS.util.hasValidAriaLabel(element) === true) {
433+
hasError = false;
434+
}
435+
428436
if (hasError === false) {
429437
// No error? Remind of obligations about equivalence of alternatives.
430438
errors.applet.generalAlt.push(element);

Tests/WCAG2/4_1_2_Aria_Labels.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
Standard: WCAG2AAA
88
Assert: Error *.H91.* on #unlabelledButton
99
Assert: No Error *.H91 on #labelledButton
10-
Assert: Error *.H91.* on #emptyLabelledButton
11-
Assert: No Error * on #labelledByButton
10+
Assert: Error *.H91.Button.Name on #emptyLabelledButton
11+
Assert: No Error *.H91.Button.Name on #labelledByButton
12+
Assert: Error *.H53.ARIA6 on #objectNoLabel
13+
Assert: No Error *.H53.ARIA6 on #objectLabelledBy
14+
Assert: No Error *.H53.ARIA6 on #objectLabel
1215
-->
1316
</head>
1417
<body>
@@ -32,6 +35,13 @@
3235
<input id="labelledByButton" type="text" aria-labelledby="billing name"/>
3336
</div>
3437

38+
<object id="objectNoLabel" data="x.jpg"></object>
39+
40+
<object id="objectLabelledBy" data="x.jpg" aria-labelledby="monkey"></object>
41+
<div id="monkey">My monkey</div>
42+
43+
<object id="objectLabel" data="x.jpg" aria-label="monkey"></object>
44+
3545
</form>
3646
</body>
3747
</html>

0 commit comments

Comments
 (0)