🏁 fix clearInterval compatible bug in ie10 and ie11 (#1490)

Co-authored-by: Kuitos <kuitos.lau@gmail.com>
This commit is contained in:
xinhailishi 2021-06-16 12:28:51 +08:00 committed by GitHub
parent 7ae60e3f7f
commit 6de0ac9721
3 changed files with 12 additions and 13 deletions

View File

@ -320,12 +320,13 @@ export async function loadApp<T extends ObjectType>(
unmountSandbox = sandboxContainer.unmount;
}
const { beforeUnmount = [], afterUnmount = [], afterMount = [], beforeMount = [], beforeLoad = [] } = mergeWith(
{},
getAddOns(global, assetPublicPath),
lifeCycles,
(v1, v2) => concat(v1 ?? [], v2 ?? []),
);
const {
beforeUnmount = [],
afterUnmount = [],
afterMount = [],
beforeMount = [],
beforeLoad = [],
} = mergeWith({}, getAddOns(global, assetPublicPath), lifeCycles, (v1, v2) => concat(v1 ?? [], v2 ?? []));
await execHooksChain(toArray(beforeLoad), app, global);
@ -338,11 +339,8 @@ export async function loadApp<T extends ObjectType>(
sandboxContainer?.instance?.latestSetProp,
);
const {
onGlobalStateChange,
setGlobalState,
offGlobalStateChange,
}: Record<string, CallableFunction> = getMicroAppStateActions(appInstanceId);
const { onGlobalStateChange, setGlobalState, offGlobalStateChange }: Record<string, CallableFunction> =
getMicroAppStateActions(appInstanceId);
// FIXME temporary way
const syncAppWrapperElement2Sandbox = (element: HTMLElement | null) => (initialAppWrapperElement = element);

View File

@ -14,7 +14,7 @@ export default function patch(global: Window) {
global.clearInterval = (intervalId: number) => {
intervals = intervals.filter((id) => id !== intervalId);
return rawWindowClearInterval(intervalId);
return rawWindowClearInterval.call(window, intervalId as any);
};
global.setInterval = (handler: CallableFunction, timeout?: number, ...args: any[]) => {

View File

@ -8,7 +8,8 @@ import { SandBoxType } from '../interfaces';
function iter(obj: typeof window, callbackFn: (prop: any) => void) {
// eslint-disable-next-line guard-for-in, no-restricted-syntax
for (const prop in obj) {
if (obj.hasOwnProperty(prop)) {
// patch for clearInterval for compatible reason, see #1490
if (obj.hasOwnProperty(prop) || prop === 'clearInterval') {
callbackFn(prop);
}
}