accessible-name.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.computeAccessibleName = computeAccessibleName;
  4. var _accessibleNameAndDescription = require("./accessible-name-and-description");
  5. var _util = require("./util");
  6. /**
  7. * https://w3c.github.io/aria/#namefromprohibited
  8. */
  9. function prohibitsNaming(node) {
  10. return (0, _util.hasAnyConcreteRoles)(node, ["caption", "code", "deletion", "emphasis", "generic", "insertion", "paragraph", "presentation", "strong", "subscript", "superscript"]);
  11. }
  12. /**
  13. * implements https://w3c.github.io/accname/#mapping_additional_nd_name
  14. * @param root
  15. * @param [options]
  16. * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
  17. */
  18. function computeAccessibleName(root) {
  19. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  20. if (prohibitsNaming(root)) {
  21. return "";
  22. }
  23. return (0, _accessibleNameAndDescription.computeTextAlternative)(root, options);
  24. }
  25. //# sourceMappingURL=accessible-name.js.map