ScramjetClient.SCRAMJET -> SCRAMJETCLIENT

This commit is contained in:
velzie 2024-08-30 16:59:52 -04:00
parent 2050fa140c
commit 5f77342d8d
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
11 changed files with 82 additions and 50 deletions

33
src/controller/frame.ts Normal file
View file

@ -0,0 +1,33 @@
import { ScramjetController } from ".";
import type { ScramjetClient } from "../client/client";
import { SCRAMJETCLIENT, SCRAMJETFRAME } from "../symbols";
export class ScramjetFrame extends EventTarget {
constructor(
private controller: ScramjetController,
public frame: HTMLIFrameElement
) {
super();
frame[SCRAMJETFRAME] = this;
}
get client(): ScramjetClient {
return this.frame.contentWindow.window[SCRAMJETCLIENT];
}
go(url: string | URL) {
if (url instanceof URL) url = url.toString();
dbg.log("navigated to", url);
this.frame.src = this.controller.encodeUrl(url);
}
back() {
this.frame.contentWindow?.history.back();
}
forward() {
this.frame.contentWindow?.history.forward();
}
}