Skip to content

Commit

Permalink
Fix for #158 and #159. Object now allows aria-label in lieu of other …
Browse files Browse the repository at this point in the history
…alternative text methods.
  • Loading branch information
ironikart committed Aug 26, 2016
1 parent efbd741 commit dec8759
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
20 changes: 14 additions & 6 deletions Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_1/1_1_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = {
var errors = this.testMediaTextAlternatives(top);

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

for (var i = 0; i < errors.object.generalAlt.length; i++) {
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');
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');
}

for (var i = 0; i < errors.applet.missingBody.length; i++) {
Expand Down Expand Up @@ -392,11 +392,14 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = {
// If we have an object as our alternative, skip it. Pass the blame onto
// the child.
if (childObject === null) {
var textAlt = HTMLCS.util.getElementTextContent(element, true);
if (textAlt === '') {
errors.object.missingBody.push(element);
if (HTMLCS.util.isStringEmpty(HTMLCS.util.getElementTextContent(element, true)) === true) {
if (HTMLCS.util.hasValidAriaLabel(element) === false) {
errors.object.missingBody.push(element);
}
} else {
errors.object.generalAlt.push(element);
if (HTMLCS.util.hasValidAriaLabel(element) === false) {
errors.object.generalAlt.push(element);
}
}
}//end if
}//end if
Expand Down Expand Up @@ -425,6 +428,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = {
hasError = true;
}

// Catch anything with a valid aria label.
if (HTMLCS.util.hasValidAriaLabel(element) === true) {
hasError = false;
}

if (hasError === false) {
// No error? Remind of obligations about equivalence of alternatives.
errors.applet.generalAlt.push(element);
Expand Down
14 changes: 12 additions & 2 deletions Tests/WCAG2/4_1_2_Aria_Labels.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
Standard: WCAG2AAA
Assert: Error *.H91.* on #unlabelledButton
Assert: No Error *.H91 on #labelledButton
Assert: Error *.H91.* on #emptyLabelledButton
Assert: No Error * on #labelledByButton
Assert: Error *.H91.Button.Name on #emptyLabelledButton
Assert: No Error *.H91.Button.Name on #labelledByButton
Assert: Error *.H53.ARIA6 on #objectNoLabel
Assert: No Error *.H53.ARIA6 on #objectLabelledBy
Assert: No Error *.H53.ARIA6 on #objectLabel
-->
</head>
<body>
Expand All @@ -32,6 +35,13 @@
<input id="labelledByButton" type="text" aria-labelledby="billing name"/>
</div>

<object id="objectNoLabel" data="x.jpg"></object>

<object id="objectLabelledBy" data="x.jpg" aria-labelledby="monkey"></object>
<div id="monkey">My monkey</div>

<object id="objectLabel" data="x.jpg" aria-label="monkey"></object>

</form>
</body>
</html>

0 comments on commit dec8759

Please sign in to comment.