From 0d84f77084fac4b4453c53ea45172ab698b12e9b Mon Sep 17 00:00:00 2001 From: velzie Date: Fri, 30 Aug 2024 17:32:28 -0400 Subject: [PATCH] whatever --- src/client/client.ts | 4 +++- src/client/natives.ts | 14 ++++++++++++++ src/types.d.ts | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/client/client.ts b/src/client/client.ts index 6281849..09a50da 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -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); diff --git a/src/client/natives.ts b/src/client/natives.ts index 39e75d5..6f5eda6 100644 --- a/src/client/natives.ts +++ b/src/client/natives.ts @@ -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!; diff --git a/src/types.d.ts b/src/types.d.ts index 9301af7..1f3fac4 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -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