From dec87593971179cbe3d8f007e6a7fcd70a6df1e1 Mon Sep 17 00:00:00 2001 From: Anthony Barnes Date: Fri, 26 Aug 2016 14:06:47 +1000 Subject: [PATCH] Fix for #158 and #159. Object now allows aria-label in lieu of other alternative text methods. --- .../Sniffs/Principle1/Guideline1_1/1_1_1.js | 20 +++++++++++++------ Tests/WCAG2/4_1_2_Aria_Labels.html | 14 +++++++++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_1/1_1_1.js b/Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_1/1_1_1.js index f7ace96b..a1e9ede0 100644 --- a/Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_1/1_1_1.js +++ b/Standards/WCAG2AAA/Sniffs/Principle1/Guideline1_1/1_1_1.js @@ -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++) { @@ -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 @@ -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); diff --git a/Tests/WCAG2/4_1_2_Aria_Labels.html b/Tests/WCAG2/4_1_2_Aria_Labels.html index da23c5bd..0c202b56 100644 --- a/Tests/WCAG2/4_1_2_Aria_Labels.html +++ b/Tests/WCAG2/4_1_2_Aria_Labels.html @@ -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 --> @@ -32,6 +35,13 @@ + + + +
My monkey
+ + +