🐛 invoking nextTick will trigger infinite angular change detection (#2439)
This commit is contained in:
parent
0b56bcb8a7
commit
bb40e63089
|
|
@ -12,6 +12,7 @@ declare global {
|
|||
__INJECTED_PUBLIC_PATH_BY_QIANKUN__?: string;
|
||||
__QIANKUN_DEVELOPMENT__?: boolean;
|
||||
Zone?: CallableFunction;
|
||||
__zone_symbol__setTimeout?: Window['setTimeout'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,11 @@ export function sleep(ms: number) {
|
|||
}
|
||||
|
||||
// Promise.then might be synchronized in Zone.js context, we need to use setTimeout instead to mock next tick.
|
||||
// Since zone.js will hijack the setTimeout callback, and notify angular to do change detection, so we need to use the __zone_symbol__setTimeout to avoid this, see https://github.com/umijs/qiankun/issues/2384
|
||||
const nextTick: (cb: () => void) => void =
|
||||
typeof window.Zone === 'function' ? setTimeout : (cb) => Promise.resolve().then(cb);
|
||||
typeof window.__zone_symbol__setTimeout === 'function'
|
||||
? window.__zone_symbol__setTimeout
|
||||
: (cb) => Promise.resolve().then(cb);
|
||||
|
||||
let globalTaskPending = false;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user