Repository navigation
Conversation
pairFor rounded to two decimals before the 4.5:1 check, so a pair at about 4.499:1 passed AA. Pass/fail now uses the unrounded ratio on every contrast decision; display rounding cannot cross 3:1, 4.5:1, or 7:1. Co-authored-by: Jang Trịnh <trinhnguyengiang@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pairForinsrc/core/ds-a11y.tsrounded the contrast ratio to two decimals and then compared that rounded number with 4.5. A pair at about 4.499:1 printed as 4.50 and was reported as passing AA for normal text. WCAG 2.2 Understanding SC 1.4.3 treats 3:1 and 4.5:1 as thresholds and says the computed ratio is not rounded when it is compared (4.499:1 does not meet 4.5:1).The same round-then-decide path was in the other contrast decisions, not only
pairFor:classifyContrastitself was already a raw comparison. Callers were handing it a pre-rounded ratio (ui color contrast,ui color scaletext and JSON, including an inline copy of the bands in the scale table).checkComputedContrast) rounded before>= required, so the same 4.499:1 pair skipped the finding. The 3:1 large-text floor had the same hole.>= 4.5on purpose, so it would agree with the audit. It now uses the same unrounded decision, so it will not select a pair the audit then fails.Pass/fail goes through
measureContrast, which classifies the unrounded ratio. Two-decimal display is kept, and it is not an input to the decision. When half-up rounding would cross 3:1, 4.5:1, or 7:1 and the true ratio is below that threshold, the displayed value stays below it (4.499 displays as 4.49, not 4.50).Test
tests/ds-a11y.test.tschecks a real pair,#5A7C87on#FFFFFF(about 4.499:1, which half-up rounding turns into 4.50), and#5A7E73on#FFFFFF(just over 4.5:1):passesNormalText === false, levelAA-large, included infailures)passesNormalText === true, levelAA)The same boundary is covered for
measureContrast, rendered contrast, the DESIGN.md audit, andui color contrast.Gates
npm run typecheck,npm run lint, andnpm run buildpassed. The contrast tests passed. A fullnpm testbefore the build reported missing-dist/cli.jsfailures; those passed afternpm run build. Two other local failures are outside this change (ui gflowparallel exit codes, and a CDP snapshot assertion on<img id="c"attribute order).