From c126353fa288f2fd73beba83b9c48ea2a16542a7 Mon Sep 17 00:00:00 2001 From: utsxvrai Date: Sat, 21 Nov 2026 15:02:43 +0530 Subject: [PATCH] fix(cli): check no longer reports text painted by a visible text-shadow as not painted --- .../cli/src/commands/layout-audit.browser.js | 8 ++++++++ .../commands/layout-audit.chromium.test.ts | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/cli/src/commands/layout-audit.browser.js b/packages/cli/src/commands/layout-audit.browser.js index 94ec061bc58..6b1ebbd4e9b 100644 --- a/packages/cli/src/commands/layout-audit.browser.js +++ b/packages/cli/src/commands/layout-audit.browser.js @@ -2318,6 +2318,13 @@ return false; } + // A shadow layer draws the glyph shapes in its own colour, so a visible one + // keeps transparent-fill text legible. + function textShadowPaints(textShadow) { + if (!textShadow || textShadow === "none") return false; + return splitTopLevelCommas(textShadow).some((layer) => colorAlpha(layer) > 0.05); + } + // Text whose glyphs paint with an effectively transparent fill renders // invisibly even though the element, its box, opacity and color all read as // present — so geometry/occlusion/contrast audits miss it (contrast reads @@ -2345,6 +2352,7 @@ colorAlpha(cs.webkitTextStrokeColor) > 0.05 ) return null; + if (textShadowPaints(cs.textShadow)) return null; const clip = cs.webkitBackgroundClip || cs.backgroundClip || ""; if (/text/i.test(clip)) { const bgImage = cs.backgroundImage || "none"; diff --git a/packages/cli/src/commands/layout-audit.chromium.test.ts b/packages/cli/src/commands/layout-audit.chromium.test.ts index 1ed52c00eda..6b62112b90b 100644 --- a/packages/cli/src/commands/layout-audit.chromium.test.ts +++ b/packages/cli/src/commands/layout-audit.chromium.test.ts @@ -555,6 +555,26 @@ describe.runIf(executablePath)("layout audit in Chromium", () => { style: "color:transparent;-webkit-text-stroke:0 #fff", flagged: true, }, + { + name: "shadow text (transparent fill, visible text-shadow)", + style: "color:#000;-webkit-text-fill-color:transparent;text-shadow:0 8px 0 rgb(255,255,255)", + flagged: false, + }, + { + name: "transparent text whose second shadow layer is visible", + style: "color:transparent;text-shadow:0 0 4px rgba(0,0,0,0),2px 2px 0 rgba(255,255,255,0.9)", + flagged: false, + }, + { + name: "transparent text with an invisible text-shadow", + style: "color:transparent;text-shadow:0 8px 0 rgba(255,255,255,0)", + flagged: true, + }, + { + name: "transparent text whose text-shadow takes the transparent color", + style: "color:transparent;text-shadow:0 8px 0", + flagged: true, + }, ])("judges $name by what it paints", async ({ style, flagged }) => { const codes = await auditCodes(`