aria-hidden-focus-matches.js 523 B

12345678910111213141516171819202122
  1. import { getComposedParent } from '../commons/dom';
  2. /**
  3. * Only match the outer-most `aria-hidden=true` element
  4. * @param {HTMLElement} el the HTMLElement to verify
  5. * @return {Boolean}
  6. */
  7. function shouldMatchElement(el) {
  8. if (!el) {
  9. return true;
  10. }
  11. if (el.getAttribute('aria-hidden') === 'true') {
  12. return false;
  13. }
  14. return shouldMatchElement(getComposedParent(el));
  15. }
  16. function ariaHiddenFocusMatches(node) {
  17. return shouldMatchElement(getComposedParent(node));
  18. }
  19. export default ariaHiddenFocusMatches;