mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 15:00:01 -04:00
ScramjetClient.SCRAMJET -> SCRAMJETCLIENT
This commit is contained in:
parent
2050fa140c
commit
5f77342d8d
11 changed files with 82 additions and 50 deletions
33
src/controller/frame.ts
Normal file
33
src/controller/frame.ts
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue