OAA WIDGET_9: Role value must be valid

Details

  • Check to see that the role is valid.

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

The value %1$S is not a valid role.

Dependencies

None

Context

*[@role]

Parameters

None

Code


   function (ruleContext) {
      var passed = true;
      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='';
      // Check to see that the role is valid
      if (!OpenAjax.a11y.aria.designPatterns[role]) passed = false;
          return new ValidationResult(passed, [ruleContext], 'role', '', [role]);
   }