diff --git a/src/client/client.ts b/src/client/client.ts index d0fc398..90074db 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -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 diff --git a/src/client/dom/open.ts b/src/client/dom/open.ts index 3ad0bdb..326dc86 100644 --- a/src/client/dom/open.ts +++ b/src/client/dom/open.ts @@ -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();