Skip to content

Commit

Permalink
fix: node.getrootnode
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Oct 15, 2024
1 parent ee85b48 commit c2570c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
unrewriteUrl,
rewriteUrl,
} from "../shared";
import type BareClientType from "@mercuryworkshop/bare-mux";
import { BareClient as BareClientType } from "@mercuryworkshop/bare-mux";
import { createWrapFn } from "./shared/wrap";
import { NavigateEvent } from "./events";
import type { URLMeta } from "../shared/rewriters/url";
Expand Down Expand Up @@ -378,6 +378,7 @@ export class ScramjetClient {
return oldDescriptor && oldDescriptor.get.call(this.this);
},
set: function (v: T) {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
oldDescriptor && oldDescriptor.set.call(this.this, v);
},
};
Expand Down
13 changes: 12 additions & 1 deletion src/client/dom/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ export default function (client: ScramjetClient, self: typeof window) {
"Node.prototype.parentElement",
"Node.prototype.previousSibling",
"Node.prototype.nextSibling",
"Node.prototype.getRootNode",
],
{
get(ctx) {
Expand All @@ -321,6 +320,18 @@ export default function (client: ScramjetClient, self: typeof window) {
}
);

client.Proxy("Node.prototype.getRootNode", {
apply(ctx) {
const n = ctx.call() as Node;
if (!(n instanceof Document)) return ctx.return(n);

const scram: ScramjetClient = n[SCRAMJETCLIENT];
if (!scram) return ctx.return(n); // ??

return ctx.return(scram.documentProxy);
},
});

client.Proxy("DOMParser.prototype.parseFromString", {
apply(ctx) {
if (ctx.args[1] === "text/html") {
Expand Down

0 comments on commit c2570c1

Please sign in to comment.