🐛 should avoid document.all accessing exception in micro app (#2465)
Co-authored-by: Kuitos <kuitos.lau@gmail.com>
This commit is contained in:
parent
a7a991c51e
commit
b315f1b9ea
|
|
@ -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)));
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user