(el: HTMLElement)
| 8 | * @returns { boolean } true if the element is tabbable or false - if not |
| 9 | */ |
| 10 | const isElementTabbable = (el: HTMLElement): boolean => { |
| 11 | if (!el) { |
| 12 | return false; |
| 13 | } |
| 14 | |
| 15 | if (el.hasAttribute("data-sap-no-tab-ref")) { |
| 16 | return false; |
| 17 | } |
| 18 | |
| 19 | if (isElementHidden(el)) { |
| 20 | return false; |
| 21 | } |
| 22 | |
| 23 | const tabIndex = el.getAttribute("tabindex"); |
| 24 | if (tabIndex !== null && tabIndex !== undefined) { |
| 25 | return parseInt(tabIndex) >= 0; |
| 26 | } |
| 27 | |
| 28 | const nodeName = el.nodeName.toLowerCase(); |
| 29 | if (nodeName === "a" || /^(input|select|textarea|button|object)$/.test(nodeName)) { |
| 30 | return !(el as HTMLLinkElement).disabled; |
| 31 | } |
| 32 | |
| 33 | return false; |
| 34 | }; |
| 35 | |
| 36 | export default isElementTabbable; |
no test coverage detected
searching dependent graphs…