mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 07:30:02 -04:00
fix: refrencing wrong globals in location proxy
This commit is contained in:
parent
293aeb2956
commit
ead9d160a9
2 changed files with 7 additions and 7 deletions
|
@ -166,8 +166,8 @@ export class ScramjetClient {
|
|||
const module = context(key);
|
||||
if (!key.endsWith(".ts")) continue;
|
||||
if (
|
||||
(key.startsWith("./dom/") && "window" in self) ||
|
||||
(key.startsWith("./worker/") && "WorkerGlobalScope" in self) ||
|
||||
(key.startsWith("./dom/") && "window" in this.global) ||
|
||||
(key.startsWith("./worker/") && "WorkerGlobalScope" in this.global) ||
|
||||
key.startsWith("./shared/")
|
||||
) {
|
||||
modules.push(module);
|
||||
|
@ -189,7 +189,7 @@ export class ScramjetClient {
|
|||
}
|
||||
|
||||
get url(): URL {
|
||||
return new URL(decodeUrl(self.location.href));
|
||||
return new URL(decodeUrl(this.global.location.href));
|
||||
}
|
||||
|
||||
set url(url: URL | string) {
|
||||
|
@ -201,7 +201,7 @@ export class ScramjetClient {
|
|||
}
|
||||
if (ev.defaultPrevented) return;
|
||||
|
||||
self.location.href = encodeUrl(ev.url, this.meta);
|
||||
this.global.location.href = encodeUrl(ev.url, this.meta);
|
||||
}
|
||||
|
||||
// below are the utilities for proxying and trapping dom APIs
|
||||
|
|
|
@ -14,10 +14,10 @@ export default function (client: ScramjetClient) {
|
|||
|
||||
if (!realwin) return ctx.return(realwin);
|
||||
|
||||
if (SCRAMJETCLIENT in realwin.self) {
|
||||
return ctx.return(realwin.self[SCRAMJETCLIENT].globalProxy.window);
|
||||
if (SCRAMJETCLIENT in realwin) {
|
||||
return ctx.return(realwin[SCRAMJETCLIENT].globalProxy.window);
|
||||
} else {
|
||||
const newclient = new ScramjetClient(realwin.self);
|
||||
const newclient = new ScramjetClient(realwin);
|
||||
// hook the opened window
|
||||
newclient.hook();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue