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))); };