UNPKG

1.07 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.focusIsHidden = void 0;
4var constants_1 = require("./constants");
5var DOMutils_1 = require("./utils/DOMutils");
6var array_1 = require("./utils/array");
7var getActiveElement_1 = require("./utils/getActiveElement");
8/**
9 * checks if focus is hidden FROM the focus-lock
10 * ie contained inside a node focus-lock shall ignore
11 *
12 * This is a utility function coupled with {@link FOCUS_ALLOW} constant
13 *
14 * @returns {boolean} focus is currently is in "allow" area
15 */
16var focusIsHidden = function (inDocument) {
17 if (inDocument === void 0) { inDocument = document; }
18 var activeElement = (0, getActiveElement_1.getActiveElement)(inDocument);
19 if (!activeElement) {
20 return false;
21 }
22 // this does not support setting FOCUS_ALLOW within shadow dom
23 return (0, array_1.toArray)(inDocument.querySelectorAll("[".concat(constants_1.FOCUS_ALLOW, "]"))).some(function (node) { return (0, DOMutils_1.contains)(node, activeElement); });
24};
25exports.focusIsHidden = focusIsHidden;