MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / getActivatableTarget

Function getActivatableTarget

core/src/utils/tap-click/index.ts:143–163  ·  view source on GitHub ↗
(ev: UIEvent)

Source from the content-addressed store, hash-verified

141
142// TODO(FW-2832): type
143const 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
165const isInstant = (el: HTMLElement) => {
166 return el.classList.contains('ion-activatable-instant');

Callers 1

pointerDownFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected