aria-roledescription-evaluate.js 777 B

12345678910111213141516171819202122232425
  1. import { getRole } from '../../commons/aria';
  2. /**
  3. * Check that `aria-roledescription` is used on a supported semantic role.
  4. *
  5. * @memberof checks
  6. * @param {String[]} options.supportedRoles List of ARIA roles that support the `aria-roledescription` attribute
  7. * @return {Mixed} True if the semantic role supports `aria-roledescription`. Undefined if the semantic role is `presentation` or `none`. False otherwise.
  8. */
  9. function ariaRoledescriptionEvaluate(node, options = {}) {
  10. const role = getRole(node);
  11. const supportedRoles = options.supportedRoles || [];
  12. if (supportedRoles.includes(role)) {
  13. return true;
  14. }
  15. if (role && role !== 'presentation' && role !== 'none') {
  16. return undefined;
  17. }
  18. return false;
  19. }
  20. export default ariaRoledescriptionEvaluate;