fix client.frame

This commit is contained in:
Percs 2024-11-05 18:05:59 -06:00
parent 18117e360a
commit c9c98bc70e
2 changed files with 10 additions and 1 deletions

View file

@ -139,7 +139,9 @@ export class ScramjetClient {
get frame(): ScramjetFrame | null {
if (!iswindow) return null;
const frame = this.global.window.frameElement;
const frame = this.descriptors["window.frameElement"]
? this.descriptors["window.frameElement"].get.call(this.global)
: this.global.window.frameElement;
if (!frame) return null; // we're top level
const sframe = frame[SCRAMJETFRAME];

View file

@ -2,6 +2,7 @@
import { ScramjetClient } from "./client";
import { nativeGetOwnPropertyDescriptor } from "./natives";
import { unrewriteUrl, rewriteUrl } from "../shared";
import { UrlChangeEvent } from "./events";
import { iswindow } from ".";
export function createLocationProxy(
@ -51,7 +52,13 @@ export function createLocationProxy(
return;
}
if (prop === "hash") {
self.location.hash = args[0];
const ev = new UrlChangeEvent(client.url.href);
if (client.frame) client.frame.dispatchEvent(ev);
return;
}
const url = new URL(client.url.href);
url[prop] = args[0];
client.url = url;