diff --git a/src/client/client.ts b/src/client/client.ts index 5ceeb9a..9b6173b 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -154,13 +154,13 @@ export class ScramjetClient { ), construct(target: string, ...args) { const original = this.store[target]; - if (!original) return; + if (!original) return null; return new original(...args); }, call(target: string, that: any, ...args) { const original = this.store[target]; - if (!original) return; + if (!original) return null; return original.call(that, ...args); }, @@ -192,13 +192,13 @@ export class ScramjetClient { ), get(target: string, that: any) { const original = this.store[target]; - if (!original) return; + if (!original) return null; return original.get.call(that); }, set(target: string, that: any, value: any) { const original = this.store[target]; - if (!original) return; + if (!original) return null; original.set.call(that, value); }, @@ -211,7 +211,11 @@ export class ScramjetClient { }, get base() { if (iswindow) { - const base = client.global.document.querySelector("base"); + const base = client.natives.call( + "Document.prototype.querySelector", + client.global.document, + "base" + ); if (base) { let url = base.getAttribute("href"); const frag = url.indexOf("#"); @@ -231,9 +235,7 @@ export class ScramjetClient { get frame(): ScramjetFrame | null { if (!iswindow) return null; - const frame = this.descriptors["window.frameElement"] - ? this.descriptors["window.frameElement"].get.call(this.global) - : this.global.window.frameElement; + const frame = this.descriptors.get("window.frameElement", this.global); if (!frame) return null; // we're top level const sframe = frame[SCRAMJETFRAME]; diff --git a/src/client/dom/intersectionobserver.ts b/src/client/dom/intersectionobserver.ts deleted file mode 100644 index 1d3ef71..0000000 --- a/src/client/dom/intersectionobserver.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ScramjetClient } from "../client"; - -export default function (client: ScramjetClient) { - client.Proxy("IntersectionObserver", { - construct(ctx) { - // Set to the real document - if (ctx.args[1] && ctx.args[1].root) ctx.args[1].root = document; - ctx.call(); - }, - }); -} diff --git a/src/client/shared/unproxy.ts b/src/client/shared/unproxy.ts index 4c2ee51..59ad11b 100644 --- a/src/client/shared/unproxy.ts +++ b/src/client/shared/unproxy.ts @@ -44,6 +44,13 @@ export default function (client: ScramjetClient, self: typeof window) { } catch {} } } + + client.Proxy("IntersectionObserver", { + construct(ctx) { + if (ctx.args[1] && ctx.args[1].root) ctx.args[1].root = self.document; + }, + }); + // this is probably not how stuff should be done but you cant run defineProperty on the window proxy so... client.Proxy("Object.defineProperty", { apply(ctx) {