mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
chore(): add stronger typing to the tapclick utility (#25316)
This commit is contained in:
@ -57,7 +57,7 @@ export const startTapClick = (config: Config) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const pointerDown = (ev: any) => {
|
const pointerDown = (ev: UIEvent) => {
|
||||||
if (activatableEle || isScrolling()) {
|
if (activatableEle || isScrolling()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -165,9 +165,17 @@ export const startTapClick = (config: Config) => {
|
|||||||
doc.addEventListener('contextmenu', onContextMenu, true);
|
doc.addEventListener('contextmenu', onContextMenu, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getActivatableTarget = (ev: any): any => {
|
const getActivatableTarget = (ev: UIEvent): any => {
|
||||||
if (ev.composedPath) {
|
if (ev.composedPath) {
|
||||||
const path = ev.composedPath() as HTMLElement[];
|
/**
|
||||||
|
* composedPath returns EventTarget[]. However,
|
||||||
|
* objects other than Element can be targets too.
|
||||||
|
* For example, AudioContext can be a target. In this
|
||||||
|
* case, we know that the event is a UIEvent so we
|
||||||
|
* can assume that the path will contain either Element
|
||||||
|
* or ShadowRoot.
|
||||||
|
*/
|
||||||
|
const path = ev.composedPath() as Element[] | ShadowRoot[];
|
||||||
for (let i = 0; i < path.length - 2; i++) {
|
for (let i = 0; i < path.length - 2; i++) {
|
||||||
const el = path[i];
|
const el = path[i];
|
||||||
if (!(el instanceof ShadowRoot) && el.classList.contains('ion-activatable')) {
|
if (!(el instanceof ShadowRoot) && el.classList.contains('ion-activatable')) {
|
||||||
@ -175,7 +183,7 @@ const getActivatableTarget = (ev: any): any => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ev.target.closest('.ion-activatable');
|
return (ev.target as Element).closest('.ion-activatable');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user