has-widget-role-evaluate.js 624 B

1234567891011121314151617181920
  1. import { getRoleType } from '../../commons/aria';
  2. /**
  3. * Check if an elements `role` attribute uses any widget or composite role values.
  4. *
  5. * Widget roles are taken from the `ariaRoles` standards object from the roles `type` property.
  6. *
  7. * @memberof checks
  8. * @return {Boolean} True if the element uses a `widget` or `composite` role. False otherwise.
  9. */
  10. function hasWidgetRoleEvaluate(node) {
  11. const role = node.getAttribute('role');
  12. if (role === null) {
  13. return false;
  14. }
  15. const roleType = getRoleType(role);
  16. return roleType === 'widget' || roleType === 'composite';
  17. }
  18. export default hasWidgetRoleEvaluate;