abstractrole-evaluate.js 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { tokenList } from '../../core/utils';
  2. import { getRoleType } from '../../commons/aria';
  3. /**
  4. * Check if an element's `role` attribute uses any abstract role values.
  5. *
  6. * Abstract roles are taken from the `ariaRoles` standards object from the roles `type` property.
  7. *
  8. * ##### Data:
  9. * <table class="props">
  10. * <thead>
  11. * <tr>
  12. * <th>Type</th>
  13. * <th>Description</th>
  14. * </tr>
  15. * </thead>
  16. * <tbody>
  17. * <tr>
  18. * <td><code>String[]</code></td>
  19. * <td>List of all abstract roles</td>
  20. * </tr>
  21. * </tbody>
  22. * </table>
  23. *
  24. * @memberof checks
  25. * @return {Boolean} True if the element uses an `abstract` role. False otherwise.
  26. */
  27. function abstractroleEvaluate(node, options, virtualNode) {
  28. const abstractRoles = tokenList(virtualNode.attr('role')).filter(
  29. role => getRoleType(role) === 'abstract'
  30. );
  31. if (abstractRoles.length > 0) {
  32. this.data(abstractRoles);
  33. return true;
  34. }
  35. return false;
  36. }
  37. export default abstractroleEvaluate;