Skip to content

Commit

Permalink
🐛 should avoid document.all accessing exception in micro app (#2465)
Browse files Browse the repository at this point in the history
Co-authored-by: Kuitos <[email protected]>
  • Loading branch information
showonne and kuitos authored Apr 19, 2023
1 parent a7a991c commit b315f1b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sandbox/patchers/dynamicAppend/forStrictSandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -89,7 +89,7 @@ function patchDocument(cfg: { sandbox: SandBox; speedy: boolean }) {

const value = (<any>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)));
};
Expand Down

1 comment on commit b315f1b

@vercel
Copy link

@vercel vercel bot commented on b315f1b Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.