Skip to content

Write HTML. Render video. Built for agents.

fix(cli): read effective text fill by property, not getPropertyValue

Vance Ingallsa8fd8562a8e9
diff --git a/packages/cli/src/commands/layout-audit.browser.js b/packages/cli/src/commands/layout-audit.browser.js
index f7d045ec30..20e1a7fd59 100644
--- a/packages/cli/src/commands/layout-audit.browser.js
+++ b/packages/cli/src/commands/layout-audit.browser.js
@@ -812,12 +812,12 @@
const text = textContentFor(element);
if (!text) return null;
const cs = getComputedStyle(element);
- const fill = cs.getPropertyValue("-webkit-text-fill-color") || cs.color;
+ // Vendor computed-style props are read by property (camelCase), matching
+ // the rest of this script; `webkitTextFillColor` computes to `color` when
+ // unset, so it is the effective fill directly.
+ const fill = cs.webkitTextFillColor || cs.color;
if (colorAlpha(fill) > 0.05) return null;
- const clip =
- cs.getPropertyValue("-webkit-background-clip") ||
- cs.getPropertyValue("background-clip") ||
- "";
+ const clip = cs.webkitBackgroundClip || cs.backgroundClip || "";
if (/text/i.test(clip)) return null;
return {
code: "text_not_painted",
diff --git a/packages/cli/src/commands/layout-audit.browser.test.ts b/packages/cli/src/commands/layout-audit.browser.test.ts
index 821bad8c14..e6860cf8d0 100644
--- a/packages/cli/src/commands/layout-audit.browser.test.ts
+++ b/packages/cli/src/commands/layout-audit.browser.test.ts
@@ -346,6 +346,56 @@ it("uses the bridge opacity floor across the ancestor chain", () => {
expect(candidates.some((candidate) => candidate.selector === "#stacked-copy")).toBe(true);
});
+describe("layout-audit.browser invisible text", () => {
+ afterEach(() => {
+ vi.restoreAllMocks();
+ document.body.innerHTML = "";
+ delete (window as unknown as { __hyperframesLayoutAudit?: unknown }).__hyperframesLayoutAudit;
+ clearGeometryCollector();
+ });
+
+ function invisibleTextScene(headlineStyle: Partial<CSSStyleDeclaration>): AuditIssue[] {
+ document.body.innerHTML = `
+ <div id="root" data-composition-id="main" data-width="640" data-height="360">
+ <div id="headline">Headline copy</div>
+ </div>
+ `;
+ installGeometry(
+ {
+ root: rect({ left: 0, top: 0, width: 640, height: 360 }),
+ headline: rect({ left: 40, top: 150, width: 300, height: 56 }),
+ text: rect({ left: 40, top: 150, width: 300, height: 56 }),
+ },
+ { headline: headlineStyle },
+ );
+ installAuditScript();
+ return runAudit();
+ }
+
+ it("flags text whose -webkit-text-fill-color is transparent", () => {
+ const issues = invisibleTextScene({
+ color: "rgb(255, 255, 255)",
+ webkitTextFillColor: "rgba(0, 0, 0, 0)",
+ } as unknown as Partial<CSSStyleDeclaration>);
+ const invisible = issues.find((issue) => issue.code === "text_not_painted");
+ expect(invisible).toMatchObject({ selector: "#headline", severity: "error" });
+ });
+
+ it("does not flag text with an opaque color and default fill", () => {
+ const issues = invisibleTextScene({ color: "rgb(255, 255, 255)" });
+ expect(issues.some((issue) => issue.code === "text_not_painted")).toBe(false);
+ });
+
+ it("does not flag gradient text (transparent fill clipped to the glyphs)", () => {
+ const issues = invisibleTextScene({
+ color: "rgb(255, 255, 255)",
+ webkitTextFillColor: "rgba(0, 0, 0, 0)",
+ webkitBackgroundClip: "text",
+ } as unknown as Partial<CSSStyleDeclaration>);
+ expect(issues.some((issue) => issue.code === "text_not_painted")).toBe(false);
+ });
+});
+
describe("layout-audit.browser content overlap", () => {
afterEach(() => {
vi.restoreAllMocks();