Repository navigation
fix(rules): design tokens no longer make every control unconfirmed; a show over hidden is unconfirmed beside an unread sheet #938 - #942
Merged
Conversation
… show over hidden is unconfirmed beside an unread sheet #938 A :root block of custom properties whose names or values mention display (--font-display, WordPress's Display preset) beside a calc() or var() made every element unknown, so unnamed controls warned where they should fail. The declaration reader now cuts a block into declarations the way a browser's tokenizer does; only display, visibility and all can hide, so custom properties and other properties are skipped whatever they hold. An escape outside a string, or a string a newline cuts, still makes the block unknown. :root narrows a rule's subject to <html>. A <style> rule or plain inline style that shows an element the browser hides by default (hidden, a closed dialog, a popover) is now unknown on a page with an unread stylesheet, where [hidden]{display:none!important} keeps it hidden. An inline display !important still settles it. Also fixes "A element" in a11y/aria-command-name's solution text. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Reviewed the diff (declaration-level CSS scanning in
Test coverage is good. It covers the issue repro, the WordPress global-styles shape and the Bootstrap |
Closed
3 tasks done
Contributor
Author
|
Review triage. None of these needs a code change:
The one red check on the first run, CLI tests, was an unrelated |
This was referenced Oct 20, 2026
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.
Closes #938.
Problem
Since #921 the a11y checks that skip hidden controls read
<style>blocks. That caused two regressions.:rootblock of custom properties whose names or values mentiondisplay, next to acalc()orvar(), made every element "unknown". Examples are--font-display: swapand the "Display" typography preset in WordPress global styles. Every unnamed control went from fail to<check>-unconfirmed. Two causes:readDeclarationsread the whole block as unreadable, and:rootwas indexed as "could match any element".<style>rule that shows ahiddencontrol was applied even when the page loads an external sheet. The usual case is Bootstrap's[hidden]{display:none!important}, which keeps the control hidden. The control became a false FAIL; v0.0.117 skipped it.Fix
packages/rules/src/shared/page-styles.ts):scanDeclarationscuts a block into declarations the way the CSS tokenizer does. It respects strings, comments,(,[and{blocks, and unquotedurl(…).display,visibilityoralldeclaration can hide. Custom properties and every other property are skipped whatever their values hold.displayandvisibilitydeclarations are still read strictly.url(token; codex found theu\72l(case), a string cut by a newline, or a property name that is not a plain identifier and mentions either property.mayAnimatenow comes from declaration names, so a custom property that mentionsanimationno longer marks<html>as animated.:rootnarrows a rule's subject to<html>.static-hidden.ts): a<style>rule or a plain inline style that shows an element the user-agent stylesheet hides (hidden, a closed<dialog>, apopover) is "unknown" on a page with an unread stylesheet. Only an inlinedisplay … !importantsettles it, since no sheet rule outranks it. With every sheet read, the show is still settled, as Chromium renders it.a11y/aria-command-name's solution text said "A element"; it now says "An element".button-nameuses the sharedUNCONFIRMED_CHECK_SUFFIX(follow-up from the fix(rules): an unconfirmed control resolves the prior fail it replaced #935 #936 review).Acceptance criteria
A
<style>rule whose declarations are all custom properties no longer makes any element'sdisplayorvisibilityunknown. Covered bystatic-hidden.test.ts: "a :root block of custom properties leaves every element settled" and the inline-reader cases.:root(andhtml) as a subject applies to<html>only. Covered byparseSelector(":root")(subject taghtml) and "a child that sets visibility itself is settled".htmlwas already a decided tag selector.With the repro,
a11y/button-namereportsbutton-namefail, not unconfirmed. Covered bya11y-root-custom-properties-938.test.ts, which runs the repro through all seven rules (8 checks).github.blog no longer reports its unnamed controls as unconfirmed because of its
:rootglobal styles. On a 20-page quick offline audit, A/B on the same HOME:The one page left is the homepage. There, WordPress core's undecidable show-only rules (
.wp-block-image>a{display:inline-block}, the lightboxbutton{display:flex}) still make links and buttons unknown. Filed as a11y: an undecidable <style> rule that can only show an element makes every element it could match unconfirmed #940.A
<style>rule that would show a control hidden byhidden, a closed<dialog>or apopoverdoes not turn a skip into a fail on a page that loads an external stylesheet; the control is unconfirmed. Covered forhidden, closed dialog, popover, a plain inline show, an inline!importantshow, and no external sheet.Regression tests cover the custom-property
:rootblock, a WordPress-style presets block (synthetic github.blog shape) and the external-stylesheet[hidden]case.Tests
static-hidden-chromium.json, rendered in chrome-headless-shell 1248. Each matches the new verdict, or the verdict is safer ("unknown" where Chromium hides). Examples:[hidden]{display:none!important}plus a<style>show renders hidden;!importantshow renders shown;url(row renders shown.squirrel skill impact
None. No flag, output format or report field changes.
docs/rules/a11y/button-name.mdxandaria-hidden-focus.mdxare updated.