🐛 should avoid document.all accessing exception in micro app (#2465)

Co-authored-by: Kuitos <kuitos.lau@gmail.com>
This commit is contained in:
Jinghui Chen 2023-04-19 17:46:43 +08:00 committed by GitHub
parent a7a991c51e
commit b315f1b9ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@
*/ */
import type { Freer, SandBox } from '../../../interfaces'; import type { Freer, SandBox } from '../../../interfaces';
import { isBoundedFunction, nativeDocument, nativeGlobal } from '../../../utils'; import { isBoundedFunction, nativeDocument, nativeGlobal, isCallable } from '../../../utils';
import { getCurrentRunningApp } from '../../common'; import { getCurrentRunningApp } from '../../common';
import type { ContainerConfig } from './common'; import type { ContainerConfig } from './common';
import { import {
@ -89,7 +89,7 @@ function patchDocument(cfg: { sandbox: SandBox; speedy: boolean }) {
const value = (<any>target)[p]; const value = (<any>target)[p];
// must rebind the function to the target otherwise it will cause illegal invocation error // must rebind the function to the target otherwise it will cause illegal invocation error
if (typeof value === 'function' && !isBoundedFunction(value)) { if (isCallable(value) && !isBoundedFunction(value)) {
return function proxyFunction(...args: unknown[]) { return function proxyFunction(...args: unknown[]) {
return value.call(target, ...args.map((arg) => (arg === receiver ? target : arg))); return value.call(target, ...args.map((arg) => (arg === receiver ? target : arg)));
}; };