Repository navigation
fix(check): keep the outline a word inherits from its caption in contrast - #7698
Open
wonjangcloud9 wants to merge 1 commit into
Open
wonjangcloud9 wants to merge 1 commit into
wonjangcloud9 wants to merge 1 commit into
Conversation
…rast __contrastAuditPrepare hid each text element's colour and stroke as it walked the tree. -webkit-text-stroke and color are inherited, so once an outlined caption was hidden, a highlighted word inside it (<em> with its own fill and the caption's stroke) read its stroke as transparent. The word was judged by its fill alone: a yellow keyword with a 12px black outline on a yellow map was reported as 1.18:1. A child that inherits its colour was skipped outright (its colour read as transparent), so it was never measured. Read every candidate first and hide the paint after the walk. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
What
check's contrast audit now counts the outline that a highlighted word inherits from its caption. On main, a yellow keyword inside a black-outlined caption on a yellow background was reported as1.18:1. A side effect of the same fix: a child text element that inherits its colour from its parent (<div>… <b>word</b></div>) is now measured. Before, it was skipped without a message.Why
A vertical map Short had captions like this:
The frame reads fine, because the black outline separates the yellow word from the yellow country fill.
checkstill reported:The audit already counts a solid
-webkit-text-stroke(it uses whichever of fill or stroke gives the stronger edge), and an<em>that declares its own stroke passes. The bug is ordering.__contrastAuditPreparehides each element's own paint (color,fill,-webkit-text-stroke-color→transparent !important) at the moment it visits that element. It visits.capbefore the<em>inside it. Both properties are inherited, so when the walk reaches the<em>, its computed-webkit-text-stroke-coloris the caption'stransparent. The stroke is dropped (stroke[3] <= 0.01) and the word is judged by its fill alone. The same ordering makes a child that inheritscolorread as transparent, and the walk skips it (fg[3] <= 0.01).Related work
text-shadowoutlines (a stack of0 0 Npx #000shadows) still count as no outline, and the shadow stays visible in the background sample. That is a separate design question.How
packages/cli/src/commands/contrast-audit.browser.js: the walk now only reads (colour, stroke, size, backdrop) and records which elements to hide. The hide moves intohideOwnPaint, the same code unchanged, and runs once after the walk, in the same order as the candidates, pushing the same restore records. The screenshot still happens after prepare returns, so every glyph is hidden when it is taken, as before.Test plan
Unit (
packages/cli/src/commands/layout-audit.browser.test.ts, happy-dom):keeps the stroke a keyword inherits from its outlined caption. happy-dom drops-webkit-text-stroke-color, so the test models inheritance by watching the caption'sstyle.setProperty. On main (affa03b6) with the fix stashed it fails: the keyword comes back with its fill andwcagAA: false. With the fix it passes (fg rgb(0,0,0),bg rgb(235,194,40),wcagAA: true).vitest run src/commands/ src/utils/checkBrowser.test.ts src/utils/layoutAudit.test.tspasses 2613 tests. The Chrome contrast suites (layout-audit.chromium,contrast-occlusion.chromium,contrast-solid/clip/svg-gradient.browser, run withPUPPETEER_EXECUTABLE_PATH) pass 92 tests.Real CLI,
hyperframes check --no-cache --json.Minimal repro (1080×1920, yellow band, three captions: outline on the caption, outline on the
<em>itself, and atext-shadowhalo):The original project (South Africa map Short):
Inherited colour (
<div style="color:#c9c9c9">Pale grey line with a <b>bold word</b> inside</div>on yellow):Gates: oxlint and oxfmt are clean.
fallow audit --base origin/mainpasses in the lefthook pre-commit. The comment ratchet passes, and the lefthook typecheck passes.