mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 23:10:02 -04:00
delete useless globals
This commit is contained in:
parent
4ce4226afa
commit
7f0663425a
5 changed files with 30 additions and 31 deletions
|
@ -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;
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue