Skip to content

Commit

Permalink
This resolves #165 by including role="button" in the checks for form …
Browse files Browse the repository at this point in the history
…elements ensuring that a message is still presented if no name is available to an accessibility API. An anchor that specifies role="button" is now excluded from the link value checks. It will not warn about functionality of the hyperlink (attached events), this is beyond the scope of these sniffs.
  • Loading branch information
ironikart committed Aug 24, 2016
1 parent e6a017e commit 076aed7
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions Standards/WCAG2AAA/Sniffs/Principle4/Guideline4_1/4_1_2.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = {
noContent: []
};

var elements = top.querySelectorAll('a');
var elements = top.querySelectorAll('a:not([role="button"])');

for (var el = 0; el < elements.length; el++) {
var element = elements[el];
Expand Down Expand Up @@ -152,7 +152,7 @@ var HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = {

processFormControls: function(top)
{
var elements = top.querySelectorAll('button, fieldset, input, select, textarea');
var elements = top.querySelectorAll('button, fieldset, input, select, textarea, [role="button"]');
var errors = [];
var warnings = [];

Expand Down Expand Up @@ -195,13 +195,18 @@ var HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = {
var msgSubCode = 'Input' + nodeName.substr(6, 1).toUpperCase() + nodeName.substr(7).toLowerCase();
}//end if

var requiredName = requiredNames[nodeName];
var matchingRequiredNames = requiredNames[nodeName];
var requiredValue = requiredValues[nodeName];

// Any element that doesn't have specific handling must have content.
if (!matchingRequiredNames) {
matchingRequiredNames = ['_content'];
}

// Check all possible combinations of names to ensure that one exists.
if (requiredName) {
for (var i = 0; i < requiredNames[nodeName].length; i++) {
var requiredName = requiredNames[nodeName][i];
if (matchingRequiredNames) {
for (var i = 0; i < matchingRequiredNames.length; i++) {
var requiredName = matchingRequiredNames[i];
if (requiredName === '_content') {
// Work with content.
var content = HTMLCS.util.getElementTextContent(element);
Expand Down Expand Up @@ -234,13 +239,17 @@ var HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = {
}//end if
}//end for

if (i === requiredNames[nodeName].length) {
if (i === matchingRequiredNames.length) {
var msgNodeType = nodeName + ' element';
if (nodeName.substr(0, 6) === 'input_') {
msgNodeType = nodeName.substr(6) + ' input element';
}

var builtAttrs = requiredNames[nodeName].slice(0, requiredNames[nodeName].length);
if (element.hasAttribute('role') && element.getAttribute('role') === 'button') {
msgNodeType = 'element has a role of "button" but';
}

var builtAttrs = matchingRequiredNames.slice(0, matchingRequiredNames.length);
for (var a = 0; a < builtAttrs.length; a++) {
if (builtAttrs[a] === '_content') {
builtAttrs[a] = 'element content';
Expand All @@ -260,8 +269,7 @@ var HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = {
}
}//end if

var requiredValue = requiredValues[nodeName];
var valueFound = false;
var valueFound = false;

if (requiredValue === undefined) {
// Nothing required of us.
Expand Down

0 comments on commit 076aed7

Please sign in to comment.