duplicate-id-misc-matches.js 527 B

1234567891011121314151617
  1. import { getRootNode, isFocusable } from '../commons/dom';
  2. import { isAccessibleRef } from '../commons/aria';
  3. import { escapeSelector } from '../core/utils';
  4. function duplicateIdMiscMatches(node) {
  5. const id = node.getAttribute('id').trim();
  6. const idSelector = `*[id="${escapeSelector(id)}"]`;
  7. const idMatchingElms = Array.from(
  8. getRootNode(node).querySelectorAll(idSelector)
  9. );
  10. return (
  11. !isAccessibleRef(node) && idMatchingElms.every(elm => !isFocusable(elm))
  12. );
  13. }
  14. export default duplicateIdMiscMatches;