Skip to content

Commit

Permalink
fix: scramjeclient.frame and fix client.meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Dec 17, 2024
1 parent e149e4a commit b13c2f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
18 changes: 10 additions & 8 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down Expand Up @@ -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);
},
Expand All @@ -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("#");
Expand All @@ -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];
Expand Down
11 changes: 0 additions & 11 deletions src/client/dom/intersectionobserver.ts

This file was deleted.

7 changes: 7 additions & 0 deletions src/client/shared/unproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b13c2f9

Please sign in to comment.