Comparing version 17.9.0 to 17.10.0
# CHANGELOG | ||
## 17.10.0 | ||
Improved `shouldBeFocusVisible()`. | ||
## 17.9.0 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "bobril", | ||
"version": "17.9.0", | ||
"version": "17.10.0", | ||
"description": "Component Oriented MVC Framework with virtual DOM and CSS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -617,3 +617,25 @@ import { | ||
let lastInteractionWasKeyboard = false; | ||
const inputTypesWithPermanentFocusVisible = | ||
/te(l|xt)|search|url|email|password|number|month|week|(date)?(time)?(-local)?/i; | ||
function hasAlwaysFocusVisible(element: typeof document.activeElement): boolean { | ||
if (element == null) { | ||
return false; | ||
} | ||
if ( | ||
element.tagName == "INPUT" && | ||
inputTypesWithPermanentFocusVisible.test((element as HTMLInputElement).type) && | ||
!(element as HTMLInputElement).readOnly | ||
) { | ||
return true; | ||
} | ||
if (element.tagName == "TEXTAREA" && !(element as HTMLTextAreaElement).readOnly) { | ||
return true; | ||
} | ||
return (element as HTMLElement).isContentEditable; | ||
} | ||
addEvent(bustingEventNames[0], 2, () => { | ||
@@ -624,4 +646,6 @@ lastInteractionWasKeyboard = false; | ||
addEvent("keydown", 2, () => { | ||
lastInteractionWasKeyboard = true; | ||
addEvent("keydown", 2, (ev) => { | ||
if (!ev.metaKey && !ev.altKey && !ev.ctrlKey) { | ||
lastInteractionWasKeyboard = true; | ||
} | ||
return false; | ||
@@ -631,3 +655,3 @@ }); | ||
export function shouldBeFocusVisible() { | ||
return lastInteractionWasKeyboard; | ||
return lastInteractionWasKeyboard || hasAlwaysFocusVisible(document.activeElement); | ||
} |
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
393894
9418