various cooking

This commit is contained in:
velzie 2024-07-15 14:38:53 -04:00
parent 3fb846036e
commit 408bf39ffd
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
11 changed files with 199 additions and 132 deletions

View file

@ -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;
}
});