| Original line number | Diff line number | Diff line |
|---|---|---|
| @@ -16,11 +16,16 @@ export function findAllVisible( | ||
return findAll(container, selector).filter(isElementVisible);
|
||
}
|
||
const focusableSelector =
|
||
":is(a, area)[href], :is(input, select, textarea, button):enabled, iframe, object, embed, [tabindex], [contenteditable]";
|
||
export function findAllFocusable(
|
||
container: HTMLElement,
|
||
selector: string,
|
||
): HTMLElement[] {
|
||
return findAll(container, selector).filter(isElementFocusable);
|
||
return findAll(container, `:is(${selector}):is(${focusableSelector})`).filter(
|
||
isElementVisible,
|
||
);
|
||
}
|
||
export function isElementVisible(element: HTMLElement): boolean {
|
||
| @@ -36,21 +41,7 @@ export function isElementVisible(element: HTMLElement): boolean { | ||
* Determine whether an element can be focused.
|
||
*/
|
||
export function isElementFocusable(element: HTMLElement): boolean {
|
||
if (!isElementVisible(element)) return false;
|
||
if (
|
||
element instanceof HTMLButtonElement ||
|
||
element instanceof HTMLInputElement ||
|
||
element instanceof HTMLTextAreaElement
|
||
) {
|
||
if (element.disabled || element.closest("fieldset[disabled]")) return false;
|
||
} else if (element instanceof HTMLAnchorElement) {
|
||
if (!element.href) return false;
|
||
} else {
|
||
if (element.tabIndex === -1 && !element.isContentEditable) return false;
|
||
}
|
||
return true;
|
||
return isElementVisible(element) && element.matches(focusableSelector);
|
||
}
|
||
export function arrayAt<T>(
|
||
Commit
54a793c2
authored
by
Dan Wolff
Browse files













