Skip to content

content/hidden-text misses display:none when a CSS comment precedes the property #896

Closed

Description

@nc9

Problem

content/hidden-text reads <style> rules and inline styles with parseDeclarations in packages/rules/src/content/hidden-text.ts. A CSS comment in front of a property stays in the property name, so the declaration is never recognised:

parseDeclarations("/* hide */ display:none; color: red")
// [["/* hide */ display", "none"], ["color", "red"]]

So <style>.promo { /* hide */ display: none }</style> hides .promo in a browser, but the rule does not see the display: none, and text or links hidden that way are not reported. The same applies to a comment between a property and its colon, and to inline style attributes.

Found while reviewing mobile/input-zoom (#708), which reads declarations with its own reader that treats a comment as a space.

Acceptance Criteria

  • parseDeclarations("/* hide */ display:none") returns display mapped to none
  • A comment between a property name and its colon (display/* x */: none) is read the same way
  • A comment inside a value separates tokens rather than joining them (1/**/2px is not read as 12px)
  • Fixture: <style>.x { /* hide */ display: none }</style> with text in .x gets the same content/hidden-text finding as the same rule without the comment
  • Existing hidden-text tests still pass

Activity

  1. added
    bug
    size: XS
    rules
    on Oct 16, 2026
  2. nc9 commented on Oct 17, 2026

    @nc9
    ContributorAuthor

    Note from pub#897: mobile/input-zoom has its own readDeclarations (comments read as a space, per-declaration !important, order kept) and splitSelectorList. When this is fixed, consider moving one shared declaration reader into packages/rules/src/shared/ and pointing both rules at it.

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: XS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions