fix: 84 -> 92 on acid3

This commit is contained in:
Percs 2024-11-21 23:19:06 -06:00
parent e9f4e59566
commit 4263feca61
6 changed files with 40 additions and 17 deletions

View file

@ -7,7 +7,7 @@ import { rewriteCss, rewriteHtml, rewriteJs } from "../../shared";
export default function (client: ScramjetClient, self: typeof window) {
const _nativeGetAttribute = self.Element.prototype.getAttribute;
const nativeSetAttribute = self.Element.prototype.setAttribute;
const _nativeHasAttribute = self.Element.prototype.hasAttribute;
const nativeHasAttribute = self.Element.prototype.hasAttribute;
const attrObject = {
nonce: [self.HTMLElement],
@ -158,8 +158,11 @@ export default function (client: ScramjetClient, self: typeof window) {
return ctx.return(null);
}
if (ctx.fn.call(ctx.this, `scramjet-data-${name}`)) {
ctx.return(ctx.fn.call(ctx.this, `scramjet-data-${name}`));
if (nativeHasAttribute.call(ctx.this, `scramjet-data-${name}`)) {
const attrib = ctx.fn.call(ctx.this, `scramjet-data-${name}`);
if (attrib === null) return ctx.return("");
return ctx.return(attrib);
}
},
});
@ -209,6 +212,7 @@ export default function (client: ScramjetClient, self: typeof window) {
return unrewriteHtml(ctx.get());
},
});
client.Proxy("Element.prototype.insertAdjacentHTML", {
apply(ctx) {
if (ctx.args[1])
@ -292,6 +296,9 @@ export default function (client: ScramjetClient, self: typeof window) {
"Node.prototype.parentElement",
"Node.prototype.previousSibling",
"Node.prototype.nextSibling",
"Range.prototype.commonAncestorContainer",
"AbstractRange.prototype.endContainer",
"AbstractRange.prototype.startContainer",
],
{
get(ctx) {
@ -306,6 +313,22 @@ export default function (client: ScramjetClient, self: typeof window) {
}
);
client.Proxy(
[
"HTMLIFrameElement.prototype.getSVGDocument",
"HTMLObjectElement.prototype.getSVGDocument",
"HTMLEmbedElement.prototype.getSVGDocument",
],
{
apply(ctx) {
const document = ctx.call();
if (document) {
ctx.return(ctx.this.contentDocument);
}
},
}
);
client.Proxy("Node.prototype.getRootNode", {
apply(ctx) {
const n = ctx.call() as Node;