From 0aec3c1e96df695e834966298142faf20f2d9482 Mon Sep 17 00:00:00 2001 From: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com> Date: Fri, 10 Jan 2025 18:11:59 +0530 Subject: [PATCH] fix: remove hl classes on export correctly --- src/core/highlight-vars.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/highlight-vars.js b/src/core/highlight-vars.js index a93fa69c16..b9ae3bc6f2 100644 --- a/src/core/highlight-vars.js +++ b/src/core/highlight-vars.js @@ -30,9 +30,11 @@ export async function run(conf) { // remove highlights, cleanup empty class/style attributes sub("beforesave", (/** @type {Document} */ outputDoc) => { outputDoc.querySelectorAll("var.respec-hl").forEach(el => { - el.classList.remove("respec-hl"); - const classNames = el.classList.toString().replaceAll(/respec-hl-c*/, ""); - el.classList.value = classNames.trim(); + for (const cls of el.classList.values()) { + if (cls.startsWith("respec-hl")) { + el.classList.remove(cls); + } + } if (!el.classList.length) el.removeAttribute("class"); }); });