From b7d66f0430c46150d7bf60b341eba91d0838c265 Mon Sep 17 00:00:00 2001 From: Ku6epXBOCTuK Date: Mon, 31 Aug 2026 07:07:09 +0500 Subject: [PATCH] chore: update cdp audit script --- web/scripts/audit-cdp.mjs | 157 ++++++++++++++++++++++++++++++++++---- 1 file changed, 142 insertions(+), 15 deletions(-) diff --git a/web/scripts/audit-cdp.mjs b/web/scripts/audit-cdp.mjs index 9247303..42668e1 100644 --- a/web/scripts/audit-cdp.mjs +++ b/web/scripts/audit-cdp.mjs @@ -135,6 +135,11 @@ const PROPS = [ "text-transform", "white-space", "vertical-align", + "text-decoration", + "text-decoration-line", + "text-decoration-style", + "text-decoration-color", + "text-underline-offset", ]; // Tags/elements never included in the snapshot. @@ -360,6 +365,131 @@ function snapshotDocument({ PROPS, NOISE_TAGS, INHERITED }) { // ---- cascade resolution ---------------------------------------------- // All declarations that apply to `el`, in cascade terms. + // ---- declaration parsing + shorthand expansion ------------------------ + // Reading longhands off a rule misses shorthands: e.g. a rule written + // `font: 600 14px var(--font-mono)` yields an EMPTY font-size/font-weight/ + // font-family on enumeration (getPropertyValue), and the browser even + // refuses to expand `font` inline when it contains a var(). So we parse the + // raw declaration text and expand shorthands into longhands — font by hand, + // everything else via a detached element whose cssText the browser expands. + const _tmp = document.createElement("div"); + + // Split a declaration block ("a:1; b:2") on top-level ';', ignoring braces, + // parens and quoted strings (so "content:';'" and var(...) survive). + function parseDecls(cssText) { + const parts = []; + let depth = 0, + cur = "", + inStr = null; + for (const ch of cssText) { + if (inStr) { + cur += ch; + if (ch === inStr) inStr = null; + continue; + } + if (ch === '"' || ch === "'") { + inStr = ch; + cur += ch; + continue; + } + if (ch === "(" || ch === "[") depth++; + else if (ch === ")" || ch === "]") depth--; + if (ch === ";" && depth === 0) { + if (cur.trim()) parts.push(cur.trim()); + cur = ""; + } else cur += ch; + } + if (cur.trim()) parts.push(cur.trim()); + return parts; + } + + // font — needs manual parsing: the browser can't expand it when a var() + // appears (commonly in the family), so enumerate longhands by substituting + // a plain family and reading back the resolved font sub-properties. + // Grammar: [