@vaadin/a11y-base
Advanced tools
Comparing version 24.1.13 to 24.1.14
{ | ||
"name": "@vaadin/a11y-base", | ||
"version": "24.1.13", | ||
"version": "24.1.14", | ||
"publishConfig": { | ||
@@ -35,3 +35,3 @@ "access": "public" | ||
"@polymer/polymer": "^3.0.0", | ||
"@vaadin/component-base": "~24.1.13", | ||
"@vaadin/component-base": "~24.1.14", | ||
"lit": "^2.0.0" | ||
@@ -44,3 +44,3 @@ }, | ||
}, | ||
"gitHead": "cc297ef7458e98e210db17bfb18eec7ad2932f42" | ||
"gitHead": "ddff030b439f28a7b7f61ceae706d3dd9564a2b4" | ||
} |
@@ -58,1 +58,9 @@ /** | ||
export declare function getFocusableElements(element: HTMLElement): HTMLElement[]; | ||
/** | ||
* Returns a closest focusable ancestor of an element, | ||
* or an element itself in case if it's focusable. | ||
* | ||
* The method traverses nodes in shadow DOM trees too if any. | ||
*/ | ||
export declare function getClosestFocusable(element: HTMLElement): HTMLElement | undefined; |
@@ -277,1 +277,41 @@ /** | ||
} | ||
/** | ||
* Returns an ancestor for the given node. | ||
* | ||
* @param {Node} node | ||
* @return {Node} | ||
* @private | ||
*/ | ||
function getAncestor(node) { | ||
if (node.nodeType === Node.ELEMENT_NODE && node.assignedSlot) { | ||
return node.assignedSlot; | ||
} | ||
if (node instanceof ShadowRoot) { | ||
return node.host; | ||
} | ||
return node.parentNode; | ||
} | ||
/** | ||
* Returns a closest focusable ancestor of an element, | ||
* or an element itself in case if it's focusable. | ||
* | ||
* The method traverses nodes in shadow DOM trees too if any. | ||
* | ||
* @param {HTMLElement} element | ||
* @return {HTMLElement | undefined} | ||
*/ | ||
export function getClosestFocusable(element) { | ||
let current = element; | ||
while (current !== document.body) { | ||
if (current.nodeType === Node.ELEMENT_NODE && isElementFocusable(current)) { | ||
return current; | ||
} | ||
current = getAncestor(current); | ||
} | ||
} |
@@ -254,3 +254,3 @@ /** | ||
const currentIdx = this.items.indexOf(this.focused); | ||
if (/[a-zA-Z0-9]/u.test(key) && key.length === 1) { | ||
if (/[\p{L}\p{Nd}]/u.test(key) && key.length === 1) { | ||
const idx = this._searchKey(currentIdx, key); | ||
@@ -257,0 +257,0 @@ if (idx >= 0) { |
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
103199
2738