@@ -14,12 +14,13 @@ import { getIonMode } from '../../global/ionic-global';
1414} )
1515export class App implements ComponentInterface {
1616 private focusVisible ?: FocusVisibleUtility ;
17+ private loadTimeout ?: ReturnType < typeof setTimeout > | undefined ;
1718
1819 @Element ( ) el ! : HTMLElement ;
1920
2021 componentDidLoad ( ) {
2122 if ( Build . isBrowser ) {
22- rIC ( async ( ) => {
23+ this . rIC ( async ( ) => {
2324 const isHybrid = isPlatform ( window , 'hybrid' ) ;
2425 if ( ! config . getBoolean ( '_testing' ) ) {
2526 import ( '../../utils/tap-click' ) . then ( ( module ) => module . startTapClick ( config ) ) ;
@@ -60,6 +61,12 @@ export class App implements ComponentInterface {
6061 }
6162 }
6263
64+ disconnectedCallback ( ) {
65+ if ( this . loadTimeout ) {
66+ clearTimeout ( this . loadTimeout ) ;
67+ }
68+ }
69+
6370 /**
6471 * Used to set focus on an element that uses `ion-focusable`.
6572 * Do not use this if focusing the element as a result of a keyboard
@@ -78,6 +85,14 @@ export class App implements ComponentInterface {
7885 }
7986 }
8087
88+ private rIC ( callback : ( ) => void ) {
89+ if ( 'requestIdleCallback' in window ) {
90+ ( window as any ) . requestIdleCallback ( callback ) ;
91+ } else {
92+ this . loadTimeout = setTimeout ( callback , 32 ) ;
93+ }
94+ }
95+
8196 render ( ) {
8297 const mode = getIonMode ( this ) ;
8398 return (
@@ -113,11 +128,3 @@ const needInputShims = () => {
113128
114129 return false ;
115130} ;
116-
117- const rIC = ( callback : ( ) => void ) => {
118- if ( 'requestIdleCallback' in window ) {
119- ( window as any ) . requestIdleCallback ( callback ) ;
120- } else {
121- setTimeout ( callback , 32 ) ;
122- }
123- } ;
0 commit comments