isHiddenFromScreenReader.js 926 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports["default"] = void 0;
  6. var _jsxAstUtils = require("jsx-ast-utils");
  7. /**
  8. * Returns boolean indicating that the aria-hidden prop
  9. * is present or the value is true. Will also return true if
  10. * there is an input with type='hidden'.
  11. *
  12. * <div aria-hidden /> is equivalent to the DOM as <div aria-hidden=true />.
  13. */
  14. var isHiddenFromScreenReader = function isHiddenFromScreenReader(type, attributes) {
  15. if (type.toUpperCase() === 'INPUT') {
  16. var hidden = (0, _jsxAstUtils.getLiteralPropValue)((0, _jsxAstUtils.getProp)(attributes, 'type'));
  17. if (hidden && hidden.toUpperCase() === 'HIDDEN') {
  18. return true;
  19. }
  20. }
  21. var ariaHidden = (0, _jsxAstUtils.getPropValue)((0, _jsxAstUtils.getProp)(attributes, 'aria-hidden'));
  22. return ariaHidden === true;
  23. };
  24. var _default = isHiddenFromScreenReader;
  25. exports["default"] = _default;