選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

30 行
725 B

  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = getExplicitRole;
  6. var _ariaQuery = require('aria-query');
  7. var _jsxAstUtils = require('jsx-ast-utils');
  8. /**
  9. * Returns an element's computed role, which is
  10. *
  11. * 1. The valid value of its explicit role attribute; or
  12. * 2. The implicit value of its tag.
  13. */
  14. function getExplicitRole(tag, attributes) {
  15. var explicitRole = function toLowerCase(role) {
  16. if (typeof role === 'string') {
  17. return role.toLowerCase();
  18. }
  19. return null;
  20. }((0, _jsxAstUtils.getLiteralPropValue)((0, _jsxAstUtils.getProp)(attributes, 'role')));
  21. if (_ariaQuery.roles.has(explicitRole)) {
  22. return explicitRole;
  23. }
  24. return null;
  25. }