allowed-attr.js 650 B

12345678910111213141516171819202122232425262728293031
  1. import standards from '../../standards';
  2. import getGlobalAriaAttrs from '../standards/get-global-aria-attrs';
  3. /**
  4. * Get allowed attributes for a given role
  5. * @method allowedAttr
  6. * @memberof axe.commons.aria
  7. * @instance
  8. * @param {String} role The role to check
  9. * @return {Array}
  10. */
  11. function allowedAttr(role) {
  12. const roleDef = standards.ariaRoles[role];
  13. const attrs = [...getGlobalAriaAttrs()];
  14. if (!roleDef) {
  15. return attrs;
  16. }
  17. if (roleDef.allowedAttrs) {
  18. attrs.push(...roleDef.allowedAttrs);
  19. }
  20. if (roleDef.requiredAttrs) {
  21. attrs.push(...roleDef.requiredAttrs);
  22. }
  23. return attrs;
  24. }
  25. export default allowedAttr;