From a27e904309ae995a7e9035f67a885b10ae7c463b Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:01:32 -0500 Subject: [PATCH] fix: handle all html rules properly --- src/client/dom/element.ts | 4 ++-- src/shared/rewriters/html.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index 508a1eb..48c79a2 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -123,7 +123,7 @@ export default function (client: ScramjetClient, self: typeof window) { const [name, value] = ctx.args; const ruleList = htmlRules.find((rule) => { - const r = rule[name]; + const r = rule[name.toLowerCase()]; if (!r) return false; if (r === "*") return true; if (typeof r === "function") return false; // this can't happen but ts @@ -142,7 +142,7 @@ export default function (client: ScramjetClient, self: typeof window) { const [namespace, name, value] = ctx.args; const ruleList = htmlRules.find((rule) => { - const r = rule[name]; + const r = rule[name.toLowerCase()]; if (!r) return false; if (r === "*") return true; if (typeof r === "function") return false; // this can't happen but ts diff --git a/src/shared/rewriters/html.ts b/src/shared/rewriters/html.ts index 79eacf2..735bef2 100644 --- a/src/shared/rewriters/html.ts +++ b/src/shared/rewriters/html.ts @@ -155,7 +155,6 @@ export const htmlRules: { // srcset srcset: ["img", "source"], - srcSet: ["img", "source"], imagesrcset: ["link"], }, { @@ -200,7 +199,7 @@ function traverseParsedHtml( if (node.attribs) { for (const rule of htmlRules) { for (const attr in rule) { - const sel = rule[attr]; + const sel = rule[attr.toLowerCase()]; if (typeof sel === "function") continue; if (sel === "*" || sel.includes(node.name)) {