Skip to content

a11y: a :root custom-property block makes every control on the page unconfirmed (since #921) #938

Closed

Description

@nc9

Since #921, the a11y checks that skip hidden controls read the page's <style> blocks (packages/rules/src/shared/page-styles.ts). A :root block of custom properties makes every element on the page "unknown" for display and visibility. That happens when a property name or value mentions display, visibility or all, and the block also holds a (, /, * or a quote. As a result, every unnamed button, field and dialog on the page is reported as <check>-unconfirmed (warn) instead of <check> (fail).

The pattern is common. A WordPress theme.json with a typography preset named "Display" produces it, and so do design tokens such as --font-display next to a calc() or var().

Repro

<!doctype html><html lang="en"><head><title>t</title>
<style>:root { --font-display: swap; --gap: calc(1rem + 2px) }</style>
</head><body><main><button class="x"></button></main></body></html>

On a real site, a 20-page audit of github.blog (quick, offline) has a11y/button-name, a11y/aria-labels, a11y/aria-command-name and a11y/aria-hidden-focus on 20 pages. These go from fail to unconfirmed warn. The source is the WordPress global styles :root block: --wp--custom--typography--presets--6--name: Display; ... --font: var(--text-display-shorthand).

Cause

  1. MENTIONS_HIDING (/display|visibility|\ball\b/i) matches inside custom property names and values (--font-display, name: Display).
  2. readDeclarations returns "unknown" for the whole body when it holds (, /, * or a quote, even though a custom property cannot set display or visibility.
  3. The compound that parseSelector(":root") returns has no tag, id, class or attribute. It is indexed under *, so it is uncertain for every element, though :root only matches <html>.
  4. With the root unknown, display unknown carries to every descendant.

Related

A second, smaller case comes from the same change. A <style> rule that shows a control is applied even when the page also loads an external stylesheet. Example: <link rel="stylesheet" href="bootstrap.css"> (which has [hidden]{display:none!important}) plus <style>button{display:inline-flex}</style> and <button hidden>. In a browser the button stays hidden, but main now reports it as an unnamed button fail. v0.0.117 skipped it. Hiding from a <style> block is softened when an external sheet exists, but showing is not.

Acceptance Criteria

  • A <style> rule whose declarations are all custom properties (--name: value) no longer makes any element's display or visibility unknown, whatever their names and values hold.
  • :root (and html) as a subject applies to the <html> element only, not to every element.
  • With the repro above, a11y/button-name reports button-name fail, not button-name-unconfirmed.
  • A 20-page audit of github.blog no longer reports the site's unnamed controls as unconfirmed only because of its :root global styles. Controls really hidden by an unsettled rule may still be unconfirmed.
  • A <style> rule that would show a control hidden by the hidden attribute, a closed <dialog> or a popover does not turn a skip into a fail when the page also loads an external stylesheet. It is unconfirmed instead.
  • Regression tests cover the custom-property :root block, a WordPress-style presets block, and the external-stylesheet [hidden] case.

Activity

  1. added
    bug
    size: S
    rules
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrulessize: S

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions