getImplicitRole.js 740 B

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports["default"] = getImplicitRole;
  7. var _ariaQuery = require("aria-query");
  8. var _implicitRoles = _interopRequireDefault(require("./implicitRoles"));
  9. /**
  10. * Returns an element's implicit role given its attributes and type.
  11. * Some elements only have an implicit role when certain props are defined.
  12. */
  13. function getImplicitRole(type, attributes) {
  14. var implicitRole;
  15. if (_implicitRoles["default"][type]) {
  16. implicitRole = _implicitRoles["default"][type](attributes);
  17. }
  18. if (_ariaQuery.roles.has(implicitRole)) {
  19. return implicitRole;
  20. }
  21. return null;
  22. }