delete useless globals

This commit is contained in:
velzie 2024-07-13 22:24:12 -04:00
parent 4ce4226afa
commit 7f0663425a
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
5 changed files with 30 additions and 31 deletions

View file

@ -1,10 +1,12 @@
const windowProxy = new Proxy(window, {
import { locationProxy } from "./location";
export const windowProxy = new Proxy(window, {
get(target, prop) {
const propIsString = typeof prop === "string";
if (propIsString && prop === "location") {
return target.__location;
return locationProxy;
} else if (propIsString && ["window", "top", "parent", "self", "globalThis"].includes(prop)) {
return target.__window;
return windowProxy;
}
return target[prop];
@ -19,5 +21,3 @@ const windowProxy = new Proxy(window, {
return Reflect.set(target, prop, newValue);
},
});
window.__window = windowProxy;