(el: HTMLElement)
| 2 | const rFocusable = /^(?:input|select|textarea|button)$/i; |
| 3 | |
| 4 | const isElementClickable = (el: HTMLElement): boolean => { |
| 5 | if ((el as HTMLButtonElement).disabled) { |
| 6 | return false; |
| 7 | } |
| 8 | |
| 9 | const tabIndex = el.getAttribute("tabindex"); |
| 10 | if (tabIndex !== null && tabIndex !== undefined) { |
| 11 | return parseInt(tabIndex) >= 0; |
| 12 | } |
| 13 | |
| 14 | return rFocusable.test(el.nodeName) |
| 15 | || (rClickable.test(el.nodeName) |
| 16 | && !!(el as HTMLLinkElement).href); |
| 17 | }; |
| 18 | |
| 19 | export default isElementClickable; |
no outgoing calls
no test coverage detected
searching dependent graphs…