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

@ -7,28 +7,24 @@ function urlLocation() {
loc.reload = () => location.reload();
loc.replace = (url: string) => location.replace(encodeUrl(url));
loc.toString = () => loc.href;
return loc;
}
export function LocationProxy() {
const loc = urlLocation();
const loc = urlLocation();
export const locationProxy = new Proxy(window.location, {
get(target, prop) {
return loc[prop];
},
return new Proxy(window.location, {
get(target, prop) {
return loc[prop];
},
set(obj, prop, value) {
if (prop === "href") {
location.href = encodeUrl(value);
} else {
loc[prop] = value;
}
return true;
set(obj, prop, value) {
if (prop === "href") {
location.href = encodeUrl(value);
} else {
loc[prop] = value;
}
})
}
window.__location = LocationProxy();
return true;
}
})