react-focus-lock
Advanced tools
Comparing version 2.8.0 to 2.8.1
@@ -100,2 +100,14 @@ "use strict"; | ||
var checkInHost = function checkInHost(check, el, boundary) { | ||
return el // find host equal to active element and check nested active element | ||
&& (el.host === check && (!el.activeElement || boundary.contains(el.activeElement)) // dive up | ||
|| el.parentNode && checkInHost(check, el.parentNode, boundary)); | ||
}; | ||
var withinHost = function withinHost(activeElement, workingArea) { | ||
return workingArea.some(function (area) { | ||
return checkInHost(activeElement, area, area); | ||
}); | ||
}; | ||
var activateTrap = function activateTrap() { | ||
@@ -120,3 +132,5 @@ var result = false; | ||
if (persistentFocus || focusWasOutside(crossFrame) || !isFreeFocus() || !lastActiveFocus && autoFocus) { | ||
if (workingNode && !((0, _focusLock.focusInside)(workingArea) || focusIsPortaledPair(activeElement, workingNode))) { | ||
if (workingNode && !( // active element is "inside" working area | ||
(0, _focusLock.focusInside)(workingArea) || // check for shadow-dom contained elements | ||
activeElement && withinHost(activeElement, workingArea) || focusIsPortaledPair(activeElement, workingNode))) { | ||
if (document && !lastActiveFocus && activeElement && !autoFocus) { | ||
@@ -123,0 +137,0 @@ // Check if blur() exists, which is missing on certain elements on IE |
@@ -82,2 +82,14 @@ import * as React from 'react'; | ||
var checkInHost = function checkInHost(check, el, boundary) { | ||
return el // find host equal to active element and check nested active element | ||
&& (el.host === check && (!el.activeElement || boundary.contains(el.activeElement)) // dive up | ||
|| el.parentNode && checkInHost(check, el.parentNode, boundary)); | ||
}; | ||
var withinHost = function withinHost(activeElement, workingArea) { | ||
return workingArea.some(function (area) { | ||
return checkInHost(activeElement, area, area); | ||
}); | ||
}; | ||
var activateTrap = function activateTrap() { | ||
@@ -102,3 +114,5 @@ var result = false; | ||
if (persistentFocus || focusWasOutside(crossFrame) || !isFreeFocus() || !lastActiveFocus && autoFocus) { | ||
if (workingNode && !(focusInside(workingArea) || focusIsPortaledPair(activeElement, workingNode))) { | ||
if (workingNode && !( // active element is "inside" working area | ||
focusInside(workingArea) || // check for shadow-dom contained elements | ||
activeElement && withinHost(activeElement, workingArea) || focusIsPortaledPair(activeElement, workingNode))) { | ||
if (document && !lastActiveFocus && activeElement && !autoFocus) { | ||
@@ -105,0 +119,0 @@ // Check if blur() exists, which is missing on certain elements on IE |
{ | ||
"name": "react-focus-lock", | ||
"version": "2.8.0", | ||
"version": "2.8.1", | ||
"description": "It is a trap! (for a focus)", | ||
@@ -17,3 +17,3 @@ "main": "dist/cjs/index.js", | ||
"test": "npm run test:pick -- '_tests/**/*spec.js'", | ||
"test:pick": "NODE_ENV=cjs mocha --require @babel/register --require jsdom-global/register --require _tests/spinup/scaffolding --exit", | ||
"test:pick": "NODE_ENV=cjs mocha --require @babel/register --require global-jsdom/register --require _tests/spinup/scaffolding --exit", | ||
"prepublish": "npm run lint:fix && npm run build && npm run changelog", | ||
@@ -83,4 +83,4 @@ "lint": "eslint src", | ||
"eslint-plugin-react": "^7.13.0", | ||
"jsdom": "15.1.1", | ||
"jsdom-global": "^3.0.2", | ||
"jsdom": "^16.0.0", | ||
"global-jsdom": "^8.4.0", | ||
"material-ui": "^0.20.0", | ||
@@ -87,0 +87,0 @@ "mocha": "^8.3.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76873
1593