Download wp-calypso/client/lib/dom/focus.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 829 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/dom/focus.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/dom/focus.ts
-
curl -L -o focus.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/dom/focus.ts
829 Bytes
| /** | |
| * Return the focusable children of an HTML element | |
| * @param {HTMLElement} parent HTML element to get the focusable children from | |
| * @returns {HTMLElement[]} Collection of focusable elements | |
| */ | |
| export function getFocusableElements( parent: HTMLElement ): NodeListOf< HTMLElement > { | |
| return parent.querySelectorAll( | |
| 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])' | |
| ); | |
| } | |
| /** | |
| * Return the last focusable child of an HTML element | |
| * @param {HTMLElement} parent HTML element to get the focusable child from | |
| * @returns {HTMLElement} Last focusable child | |
| */ | |
| export function getLastFocusableElement( parent: HTMLElement ): HTMLElement | undefined { | |
| const focusableElts = getFocusableElements( parent ); | |
| return focusableElts.length > 0 ? focusableElts[ focusableElts.length - 1 ] : undefined; | |
| } | |