From b315f1b9ea73c3d905e574d619b133e85ed38dc6 Mon Sep 17 00:00:00 2001 From: Jinghui Chen Date: Wed, 19 Apr 2023 17:46:43 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20should=20avoid=20document.all=20?= =?UTF-8?q?accessing=20exception=20in=20micro=20app=20(#2465)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kuitos --- src/sandbox/patchers/dynamicAppend/forStrictSandbox.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sandbox/patchers/dynamicAppend/forStrictSandbox.ts b/src/sandbox/patchers/dynamicAppend/forStrictSandbox.ts index bf66ce5..5c0cb58 100644 --- a/src/sandbox/patchers/dynamicAppend/forStrictSandbox.ts +++ b/src/sandbox/patchers/dynamicAppend/forStrictSandbox.ts @@ -4,7 +4,7 @@ */ import type { Freer, SandBox } from '../../../interfaces'; -import { isBoundedFunction, nativeDocument, nativeGlobal } from '../../../utils'; +import { isBoundedFunction, nativeDocument, nativeGlobal, isCallable } from '../../../utils'; import { getCurrentRunningApp } from '../../common'; import type { ContainerConfig } from './common'; import { @@ -89,7 +89,7 @@ function patchDocument(cfg: { sandbox: SandBox; speedy: boolean }) { const value = (target)[p]; // 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 value.call(target, ...args.map((arg) => (arg === receiver ? target : arg))); };