mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
fix: scramjeclient.frame and fix client.meta
This commit is contained in:
parent
e149e4af22
commit
b13c2f9563
3 changed files with 17 additions and 19 deletions
|
@ -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];
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
});
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue