mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
add bind proxy
This commit is contained in:
parent
817f687621
commit
cd892e3cb1
1 changed files with 12 additions and 6 deletions
|
@ -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);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue