Close two blind spots in the contrast check

Last change found a folded player's stack sitting at 2.22:1, hidden for twenty rounds
behind an exemption. So I went looking for the other exemptions rather than waiting for
the next one to surface. There were two, and neither is hiding a live fault today --
which is worth saying plainly, because it means this is a fix to the instrument and not
to the tool.

Leaf elements only

    if (el.children.length > 0) return;   // leaf text only

An element's own text stopped being measured the moment a child was added to it. The
undo control went that way two changes ago, the day a <kbd> was appended to it: its
label became invisible to this check with no sign that anything had changed. Now it
measures an element's own text nodes and leaves the descendants to their own turn,
against their own colours.

aria-hidden as a contrast exemption

The bets layer is aria-hidden because the amounts on the chips are already announced by
the seat and the action bar, and repeating them would be noise. That is a good reason
to hide them from a screen reader and no reason at all to stop checking whether a
sighted dealer can read them -- and the chips are exactly what the felt is read for.
Two different questions were being answered by one attribute.

Nothing is exempt now. If something genuinely decorative turns up, it should say so in
its own words rather than borrowing an attribute that means something else. The
watermark that the exemption was written for is gone as of the change before last.

What the widened check finds

Nothing. Zero offenders at six viewports across touch and pointer contexts, and with
the sidebar panels and the rulings sheet open. Measured from rendered pixels, the two
things that had been invisible are comfortable: the bet chip amounts read 12.65 to
13.74:1 and the undo label 8.06:1.

So the fix is proved by injection instead. Colouring the bet chip amounts #3a3a3a now
reports three offenders at 1.80:1, and colouring the undo control #2f2f2f reports it at
1.13:1. Neither was reported before.

269 tests still passing, no console errors.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb
This commit is contained in:
2026-09-01 19:21:06 -06:00
co-authored by Claude Opus 5
parent f0cfd24647
commit d297c1a2c9
+24 -7
View File
@@ -368,8 +368,18 @@ const LayoutAudit = {
: [...document.querySelectorAll("*")];
nodes.forEach(el => {
if (el.children.length > 0) return; // leaf text only
const text = (el.textContent || "").trim();
// An element's *own* text, not its descendants' — they get measured on
// their own turn, against their own colour.
//
// This used to be "leaf elements only", which quietly stopped measuring
// anything the moment a child was added to it. The undo control went that
// way the day a <kbd> was appended to it: its label became invisible to
// this check, with no sign that anything had changed.
const text = [...el.childNodes]
.filter(node => node.nodeType === 3)
.map(node => node.textContent)
.join(" ")
.trim();
if (!text) return;
const rect = el.getBoundingClientRect();
if (rect.width === 0 || rect.height === 0) return;
@@ -390,11 +400,18 @@ const LayoutAudit = {
unmeasured.push(`${this.describe(el)} :: faded (opacity ${opacity}), contrast not checked`);
return;
}
// Decoration is exempt by definition: the watermark on the felt is meant
// to be barely there, and holding it to a reading threshold would mean
// making it not a watermark. Marked aria-hidden so screen readers skip it
// too, which is the same claim expressed where it also does some good.
if (el.closest("[aria-hidden='true']")) return;
// aria-hidden used to exempt text here, on the grounds that decoration
// marked for screen readers was decoration for everyone. Those are two
// different questions and the answer differs: the bet chips on the felt are
// aria-hidden because their amounts are already announced by the seat and
// the action bar, and repeating them would be noise — but they are exactly
// what a sighted dealer reads the felt for, and this check had stopped
// looking at them. Hiding something from one audience is not a claim about
// whether the other audience can read it.
//
// Nothing is exempt now. If something genuinely decorative turns up, it
// should say so in its own words rather than borrowing an attribute that
// means something else.
const fgRaw = this.parseColour(style.color);
if (!fgRaw) return;