focus.js 387 B

123456789101112131415
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.focus = focus;
  6. var _utils = require("./utils");
  7. function focus(element) {
  8. if (!(0, _utils.isFocusable)(element)) return;
  9. const isAlreadyActive = (0, _utils.getActiveElement)(element.ownerDocument) === element;
  10. if (isAlreadyActive) return;
  11. (0, _utils.eventWrapper)(() => element.focus());
  12. }