This commit is contained in:
velzie 2024-08-30 17:32:28 -04:00
parent e0671f4648
commit 0d84f77084
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
3 changed files with 22 additions and 1 deletions

View file

@ -68,8 +68,10 @@ export class ScramjetClient {
constructor(public global: typeof globalThis) {
this.serviceWorker = this.global.navigator.serviceWorker;
if ("document" in self) {
if ("document" in global) {
this.documentProxy = createDocumentProxy(this, global);
global.document[SCRAMJETCLIENT] = this;
}
this.locationProxy = createLocationProxy(this, global);

View file

@ -1,3 +1,17 @@
export const nativeFunction = self.Function;
export const nativeGetOwnPropertyDescriptor =
self.Object.getOwnPropertyDescriptor;
// descriptors
export const nativeDefaultViewGetter = nativeGetOwnPropertyDescriptor(
Document.prototype,
"defaultView"
)!.get!;
export const nativeContentDocumentGetter = nativeGetOwnPropertyDescriptor(
HTMLIFrameElement.prototype,
"contentDocument"
)!.get!;
export const nativeContentWindowGetter = nativeGetOwnPropertyDescriptor(
HTMLIFrameElement.prototype,
"contentWindow"
)!.get!;

5
src/types.d.ts vendored
View file

@ -83,6 +83,11 @@ declare global {
[SCRAMJETCLIENT]: ScramjetClient;
}
interface HTMLDocument {
// should be the same as window
[SCRAMJETCLIENT]: ScramjetClient;
}
interface HTMLIFrameElement {
// the event target belonging to an <iframe> holding a /prefix/blah url
[SCRAMJETFRAME]: ScramjetFrame;