Files
url_tracker_tool/node_modules/focus-lock/dist/es2015/utils/tabUtils.js
Andrei 58f8093689 Rebrand from 'Redirect Intelligence v2' to 'URL Tracker Tool V2' throughout UI
- Updated all component headers and documentation
- Changed navbar and footer branding
- Updated homepage hero badge
- Modified page title in index.html
- Simplified footer text to 'Built with ❤️'
- Consistent V2 capitalization across all references
2025-08-19 19:12:23 +00:00

43 lines
2.0 KiB
JavaScript

import { FOCUS_AUTO } from '../constants';
import { toArray } from './array';
import { tabbables } from './tabbables';
var queryTabbables = tabbables.join(',');
var queryGuardTabbables = "".concat(queryTabbables, ", [data-focus-guard]");
var getFocusablesWithShadowDom = function (parent, withGuards) {
return toArray((parent.shadowRoot || parent).children).reduce(function (acc, child) {
return acc.concat(child.matches(withGuards ? queryGuardTabbables : queryTabbables) ? [child] : [], getFocusablesWithShadowDom(child));
}, []);
};
var getFocusablesWithIFrame = function (parent, withGuards) {
var _a;
// contentDocument of iframe will be null if current origin cannot access it
if (parent instanceof HTMLIFrameElement && ((_a = parent.contentDocument) === null || _a === void 0 ? void 0 : _a.body)) {
return getFocusables([parent.contentDocument.body], withGuards);
}
return [parent];
};
export var getFocusables = function (parents, withGuards) {
return parents.reduce(function (acc, parent) {
var _a;
var focusableWithShadowDom = getFocusablesWithShadowDom(parent, withGuards);
var focusableWithIframes = (_a = []).concat.apply(_a, focusableWithShadowDom.map(function (node) { return getFocusablesWithIFrame(node, withGuards); }));
return acc.concat(
// add all tabbables inside and within shadow DOMs in DOM order
focusableWithIframes,
// add if node is tabbable itself
parent.parentNode
? toArray(parent.parentNode.querySelectorAll(queryTabbables)).filter(function (node) { return node === parent; })
: []);
}, []);
};
/**
* return a list of focusable nodes within an area marked as "auto-focusable"
* @param parent
*/
export var getParentAutofocusables = function (parent) {
var parentFocus = parent.querySelectorAll("[".concat(FOCUS_AUTO, "]"));
return toArray(parentFocus)
.map(function (node) { return getFocusables([node]); })
.reduce(function (acc, nodes) { return acc.concat(nodes); }, []);
};