| 141 | |
| 142 | // TODO(FW-2832): type |
| 143 | const getActivatableTarget = (ev: UIEvent): any => { |
| 144 | if (ev.composedPath !== undefined) { |
| 145 | /** |
| 146 | * composedPath returns EventTarget[]. However, |
| 147 | * objects other than Element can be targets too. |
| 148 | * For example, AudioContext can be a target. In this |
| 149 | * case, we know that the event is a UIEvent so we |
| 150 | * can assume that the path will contain either Element |
| 151 | * or ShadowRoot. |
| 152 | */ |
| 153 | const path = ev.composedPath() as Element[] | ShadowRoot[]; |
| 154 | for (let i = 0; i < path.length - 2; i++) { |
| 155 | const el = path[i]; |
| 156 | if (!(el instanceof ShadowRoot) && el.classList.contains('ion-activatable')) { |
| 157 | return el; |
| 158 | } |
| 159 | } |
| 160 | } else { |
| 161 | return (ev.target as Element).closest('.ion-activatable'); |
| 162 | } |
| 163 | }; |
| 164 | |
| 165 | const isInstant = (el: HTMLElement) => { |
| 166 | return el.classList.contains('ion-activatable-instant'); |