@vaadin/a11y-base
Advanced tools
Comparing version 24.2.4 to 24.2.5
{ | ||
"name": "@vaadin/a11y-base", | ||
"version": "24.2.4", | ||
"version": "24.2.5", | ||
"publishConfig": { | ||
@@ -35,3 +35,3 @@ "access": "public" | ||
"@polymer/polymer": "^3.0.0", | ||
"@vaadin/component-base": "~24.2.4", | ||
"@vaadin/component-base": "~24.2.5", | ||
"lit": "^2.0.0" | ||
@@ -44,3 +44,3 @@ }, | ||
}, | ||
"gitHead": "885416de13069b7409ac90c1b323a58ac87da6ce" | ||
"gitHead": "f1c916061f1b117fa9c597d3067e7b96563f99a7" | ||
} |
@@ -58,9 +58,1 @@ /** | ||
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,41 +277,1 @@ /** | ||
} | ||
/** | ||
* 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); | ||
} | ||
} |
103097
2728