Socket
Socket
Sign inDemoInstall

focus-lock

Package Overview
Dependencies
1
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.11.5 to 0.11.6

dist/es2015/utils/safe.d.ts

3

dist/es2015/utils/getActiveElement.d.ts

@@ -1,4 +0,1 @@

/**
* returns active element from document or from nested shadowdoms
*/
export declare const getActiveElement: (inDocument?: Document | ShadowRoot | undefined) => HTMLElement | undefined;
/**
* returns active element from document or from nested shadowdoms
*/
import { safeProbe } from './safe';
export var getActiveElement = function (inDocument) {
var _a;
if (inDocument === void 0) { inDocument = document; }

@@ -13,5 +13,5 @@ if (!inDocument || !inDocument.activeElement) {

? getActiveElement(activeElement.shadowRoot)
: activeElement instanceof HTMLIFrameElement && ((_a = activeElement.contentWindow) === null || _a === void 0 ? void 0 : _a.document)
: activeElement instanceof HTMLIFrameElement && safeProbe(function () { return activeElement.contentWindow.document; })
? getActiveElement(activeElement.contentWindow.document)
: activeElement);
};

@@ -7,4 +7,3 @@ import { FOCUS_AUTO } from '../constants';

var getFocusablesWithShadowDom = function (parent, withGuards) {
var _a;
return toArray(((_a = parent.shadowRoot) === null || _a === void 0 ? void 0 : _a.children) || parent.children).reduce(function (acc, child) {
return toArray((parent.shadowRoot || parent).children).reduce(function (acc, child) {
return acc.concat(child.matches(withGuards ? queryGuardTabbables : queryTabbables) ? [child] : [], getFocusablesWithShadowDom(child));

@@ -14,3 +13,5 @@ }, []);

var getFocusablesWithIFrame = function (parent, withGuards) {
if (parent instanceof HTMLIFrameElement && parent.contentDocument) {
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);

@@ -17,0 +18,0 @@ }

@@ -1,4 +0,1 @@

/**
* returns active element from document or from nested shadowdoms
*/
export declare const getActiveElement: (inDocument?: Document | ShadowRoot | undefined) => HTMLElement | undefined;
/**
* returns active element from document or from nested shadowdoms
*/
import { safeProbe } from './safe';
export const getActiveElement = (inDocument = document) => {
var _a;
if (!inDocument || !inDocument.activeElement) {

@@ -12,5 +12,5 @@ return undefined;

? getActiveElement(activeElement.shadowRoot)
: activeElement instanceof HTMLIFrameElement && ((_a = activeElement.contentWindow) === null || _a === void 0 ? void 0 : _a.document)
: activeElement instanceof HTMLIFrameElement && safeProbe(() => activeElement.contentWindow.document)
? getActiveElement(activeElement.contentWindow.document)
: activeElement);
};

@@ -6,8 +6,7 @@ import { FOCUS_AUTO } from '../constants';

const queryGuardTabbables = `${queryTabbables}, [data-focus-guard]`;
const getFocusablesWithShadowDom = (parent, withGuards) => {
const getFocusablesWithShadowDom = (parent, withGuards) => toArray((parent.shadowRoot || parent).children).reduce((acc, child) => acc.concat(child.matches(withGuards ? queryGuardTabbables : queryTabbables) ? [child] : [], getFocusablesWithShadowDom(child)), []);
const getFocusablesWithIFrame = (parent, withGuards) => {
var _a;
return toArray(((_a = parent.shadowRoot) === null || _a === void 0 ? void 0 : _a.children) || parent.children).reduce((acc, child) => acc.concat(child.matches(withGuards ? queryGuardTabbables : queryTabbables) ? [child] : [], getFocusablesWithShadowDom(child)), []);
};
const getFocusablesWithIFrame = (parent, withGuards) => {
if (parent instanceof HTMLIFrameElement && parent.contentDocument) {
// 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);

@@ -14,0 +13,0 @@ }

@@ -1,4 +0,1 @@

/**
* returns active element from document or from nested shadowdoms
*/
export declare const getActiveElement: (inDocument?: Document | ShadowRoot | undefined) => HTMLElement | undefined;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getActiveElement = void 0;
/**
* returns active element from document or from nested shadowdoms
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getActiveElement = void 0;
var safe_1 = require("./safe");
var getActiveElement = function (inDocument) {
var _a;
if (inDocument === void 0) { inDocument = document; }

@@ -16,3 +16,3 @@ if (!inDocument || !inDocument.activeElement) {

? (0, exports.getActiveElement)(activeElement.shadowRoot)
: activeElement instanceof HTMLIFrameElement && ((_a = activeElement.contentWindow) === null || _a === void 0 ? void 0 : _a.document)
: activeElement instanceof HTMLIFrameElement && (0, safe_1.safeProbe)(function () { return activeElement.contentWindow.document; })
? (0, exports.getActiveElement)(activeElement.contentWindow.document)

@@ -19,0 +19,0 @@ : activeElement);

@@ -10,4 +10,3 @@ "use strict";

var getFocusablesWithShadowDom = function (parent, withGuards) {
var _a;
return (0, array_1.toArray)(((_a = parent.shadowRoot) === null || _a === void 0 ? void 0 : _a.children) || parent.children).reduce(function (acc, child) {
return (0, array_1.toArray)((parent.shadowRoot || parent).children).reduce(function (acc, child) {
return acc.concat(child.matches(withGuards ? queryGuardTabbables : queryTabbables) ? [child] : [], getFocusablesWithShadowDom(child));

@@ -17,3 +16,5 @@ }, []);

var getFocusablesWithIFrame = function (parent, withGuards) {
if (parent instanceof HTMLIFrameElement && parent.contentDocument) {
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 (0, exports.getFocusables)([parent.contentDocument.body], withGuards);

@@ -20,0 +21,0 @@ }

{
"name": "focus-lock",
"version": "0.11.5",
"version": "0.11.6",
"description": "DOM trap for a focus",

@@ -5,0 +5,0 @@ "main": "dist/es5/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc