mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
various cooking
This commit is contained in:
parent
3fb846036e
commit
408bf39ffd
11 changed files with 199 additions and 132 deletions
|
@ -24,7 +24,9 @@ export const windowProxy = new Proxy(window, {
|
|||
|
||||
const value = Reflect.get(target, prop);
|
||||
|
||||
if (typeof value === "function") {
|
||||
|
||||
// this is bad! i don't know what the right thing to do is
|
||||
if (typeof value === "function" && value != Object) {
|
||||
return value.bind(target);
|
||||
}
|
||||
|
||||
|
@ -45,3 +47,22 @@ export const windowProxy = new Proxy(window, {
|
|||
return Reflect.set(target, prop, newValue);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
export const documentProxy = new Proxy(document, {
|
||||
get(target, prop) {
|
||||
const propIsString = typeof prop === "string";
|
||||
|
||||
if (propIsString && prop === "location") {
|
||||
return locationProxy;
|
||||
}
|
||||
|
||||
const value = Reflect.get(target, prop);
|
||||
|
||||
if (typeof value === "function") {
|
||||
return value.bind(target);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue