🧑‍💻not rebind a bounded function of document (#2412)

This commit is contained in:
Kuitos 2023-02-26 16:49:55 +08:00 committed by GitHub
parent 97af9ab187
commit 901dac8c7b
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 { nativeDocument, nativeGlobal } from '../../../utils';
import { isBoundedFunction, nativeDocument, nativeGlobal } from '../../../utils';
import { getCurrentRunningApp } from '../../common';
import type { ContainerConfig } from './common';
import {
@ -59,7 +59,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') {
if (typeof value === 'function' && !isBoundedFunction(value)) {
return value.bind(target);
}