Files
GNX-mailEnterprise/frontend/node_modules/@testing-library/user-event/dist/utils/focus/getActiveElement.js
Iliyan Angelov c67067a2a4 Mail
2025-09-14 23:24:25 +03:00

26 lines
729 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getActiveElement = getActiveElement;
var _isDisabled = require("../misc/isDisabled");
function getActiveElement(document) {
const activeElement = document.activeElement;
if (activeElement != null && activeElement.shadowRoot) {
return getActiveElement(activeElement.shadowRoot);
} else {
// Browser does not yield disabled elements as document.activeElement - jsdom does
if ((0, _isDisabled.isDisabled)(activeElement)) {
return document.ownerDocument ? // TODO: verify behavior in ShadowRoot
/* istanbul ignore next */
document.ownerDocument.body : document.body;
}
return activeElement;
}
}