accessible-name.mjs 906 B

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