duplicate-id-active-matches.js 507 B

123456789101112131415
  1. import { getRootNode, isFocusable } from '../commons/dom';
  2. import { isAccessibleRef } from '../commons/aria';
  3. import { escapeSelector } from '../core/utils';
  4. function duplicateIdActiveMatches(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 !isAccessibleRef(node) && idMatchingElms.some(isFocusable);
  11. }
  12. export default duplicateIdActiveMatches;