File size: 729 Bytes
b1bbd1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"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;
  }
}