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"); }); });