-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix(a11y): composite alpha when measuring contrast ratios #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KhyFee
wants to merge
4
commits into
philaconvalley:main
Choose a base branch
from
KhyFee:fix/contrast-alpha-117
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4621c8c
fix(a11y): composite translucent fg when measuring contrast (#117)
KhyFee dfa7b8b
fix(test): address review on contrast helper (format, % alpha, pin ra…
KhyFee 4a1a6ab
fix(a11y): harden contrast helper parsing for alpha and modern syntax
KhyFee e60590b
fix(a11y): composite translucent ancestor backgrounds in contrast helper
KhyFee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
%support applies to the colour channels too, not just alpha, and misparses them silently.parseRgba('rgb(100%, 40%, 66%)')returnsrgb: [1, 0.4, 0.66], whichrelativeLuminancethen divides by 255 — a bright pink is measured as near-black and the ratio is garbage, with no error raised. The same silent-nonsense path swallows any non-legacy serialization:color(srgb 1 0.4 0.66)→[1, 0.4, 0.66],oklch(0.7 0.15 20)→[0.7, 0.15, 20].This is latent today (Tailwind 3.4 emits legacy
rgb()/rgba()and Chromium serializes computed colours that way), but it's exactly the "modern syntax" the guard on line 37 claims to cover — and that guard never actually fires for85%, since the map above already converted it to0.85. Rejecting a%on any of the first three components, or a function name other thanrgb/rgba, would make the failure loud instead of a wrong number.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks — latest commit rejects
%on RGB channels and non-rgb/rgbafunctions, while still converting percentage alpha.