File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -56,17 +56,18 @@ export function createAppContainer(appInfo: interfaces.AppInfo) {
56
56
/**
57
57
* Wait for the specified dom ready tool method
58
58
*/
59
- function waitElementReady ( selector , callback ) {
59
+ function waitElementReady ( selector , callback , leftTime ) {
60
+ const timeInterval = 50 ;
60
61
const elem = document . querySelector ( selector ) ;
61
62
62
- if ( elem !== null ) {
63
+ if ( elem !== null || leftTime <= 0 ) {
63
64
callback ( elem ) ;
64
65
return ;
65
66
}
66
67
67
68
setTimeout ( function ( ) {
68
- waitElementReady ( selector , callback ) ;
69
- } , 50 ) ;
69
+ waitElementReady ( selector , callback , leftTime - timeInterval ) ;
70
+ } , timeInterval ) ;
70
71
}
71
72
72
73
function delay ( duration ) {
@@ -77,9 +78,13 @@ function delay(duration) {
77
78
78
79
function waitElement ( selector , timeout = 3000 ) {
79
80
const waitPromise = new Promise ( function ( resolve ) {
80
- waitElementReady ( selector , function ( elem : Element ) {
81
- return resolve ( elem ) ;
82
- } ) ;
81
+ waitElementReady (
82
+ selector ,
83
+ function ( elem : Element ) {
84
+ return resolve ( elem ) ;
85
+ } ,
86
+ timeout
87
+ ) ;
83
88
} ) ;
84
89
return Promise . race ( [ delay ( timeout ) , waitPromise ] ) ;
85
90
}
You can’t perform that action at this time.
0 commit comments