mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
perf(angular): skip zone
This commit is contained in:
@ -203,15 +203,6 @@ const overlayAnimation = async (
|
||||
return hasCompleted;
|
||||
};
|
||||
|
||||
export const autoFocus = (containerEl: HTMLElement): HTMLElement | undefined => {
|
||||
const focusableEls = containerEl.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');
|
||||
if (focusableEls.length > 0) {
|
||||
const el = focusableEls[0] as HTMLInputElement;
|
||||
el.focus();
|
||||
return el;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const eventMethod = <T>(element: HTMLElement, eventName: string): Promise<T> => {
|
||||
let resolve: (detail: T) => void;
|
||||
@ -244,4 +235,20 @@ const isDescendant = (parent: HTMLElement, child: HTMLElement | null) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
const defaultGate = (h: any) => h();
|
||||
|
||||
export const safeCall = (handler: any, arg?: any) => {
|
||||
if (typeof handler === 'function') {
|
||||
const jmp = config.get('_zoneGate', defaultGate);
|
||||
return jmp(() => {
|
||||
try {
|
||||
return handler(arg);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const BACKDROP = 'backdrop';
|
||||
|
Reference in New Issue
Block a user