add bind proxy

This commit is contained in:
velzie 2024-07-18 21:34:43 -04:00
parent 817f687621
commit cd892e3cb1
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F

View file

@ -15,12 +15,6 @@ export const windowProxy = new Proxy(window, {
return window.parent;
} else if (propIsString && prop === "$scramjet") {
return;
} else if (propIsString && prop === "addEventListener") {
return new Proxy(window.addEventListener, {
apply(target1, thisArg, argArray) {
window.addEventListener(argArray[0], argArray[1]);
},
});
}
const value = Reflect.get(target, prop);
@ -107,3 +101,15 @@ Function.prototype.call = new Proxy(Function.prototype.call, {
return Reflect.apply(target, thisArg, argArray);
},
});
Function.prototype.bind = new Proxy(Function.prototype.bind, {
apply(target, thisArg, argArray) {
if (argArray[0] === windowProxy) {
argArray[0] = window;
} else if (argArray[0] === documentProxy) {
argArray[0] = document;
}
return Reflect.apply(target, thisArg, argArray);
},
});