OAA WIDGET_1: Check aria properties and states for valid roles and properties

Details

  • Check aria properties and states to make sure they are associated with a valid role.
  • A role value of null indicates no role attribute is present in (FF,Opera, Safari, Chrome).
  • ’’ value indicates the role is set to an empty string for all browsers except IE, which also returns ’’.
  • If no role attribute is present neither of these values allow for unsupported state to be tested.

Rulesets

WCAG 2.0 Requirement 4.1.2 Name, Role, Value
Status: Accepted
Severity: Violation
Priority: Priority 1
IITAA 1.0 13.1 Ensure that scripted functions are usable with assistive technologies.
Type:
Severity: Violation
Priority: Priority 1
Status: Accepted

Markup References

Validation Code

Message

ARIA attribute %1$S is cannot be used with role=%2$S.

Dependencies

None

Context

.containsAriaAttr

Parameters

None

Code


   function (ruleContext) {
      var passed = true;
      var attrNameArr = new Array();
      var designPatterns = OpenAjax.a11y.aria.designPatterns;

      //Get the role value
      var role = ruleContext.getAttribute("role");
      // - a role value of null indicates no role attribute is present in (FF,Opera, Safari, Chrome).
      // - '' value indicates the role is set to an empty string for all browsers except
      //      IE which also returns '' if no role attribute is present
      // neither of these values allow for unsupported state to be tested
          
      // Make sure the role value is consistent with IE as you don't want to push a null on the stack
      if (role==null)
         role='';
      // If there is a valid role check to see that the states are supported
      if ((role != '') && designPatterns[role]) {
         for (var a = 0; a < ruleContext.attributes.length; a++) {
            if (OpenAjax.a11y.util.isDefinedAriaAttributeAtIndex(ruleContext, a)) {
               var attrName = ruleContext.attributes[a].name;
               var found = OpenAjax.a11y.xbrowser.indexOf(OpenAjax.a11y.aria.globalProperties, attrName) >= 0;
               if (!found && designPatterns[role].reqProps != null) {
                  found = OpenAjax.a11y.xbrowser.indexOf(designPatterns[role].reqProps, attrName) >= 0;
               }
               if (!found && designPatterns[role].props != null) {
                  found = OpenAjax.a11y.xbrowser.indexOf(designPatterns[role].props, attrName) >= 0;
               }
               if (!found) attrNameArr.push(attrName);
            }
         }
      }
      var retMsg = new Array();
      retMsg.push (attrNameArr.toString());
      retMsg.push (role);

      var passed = attrNameArr.length == 0;
      return new ValidationResult(passed, [ruleContext], attrNameArr, '', retMsg);
   }