Skip to content

stylesheet: drop bang comments written inside a rule - #1276

Merged
samoht merged 3 commits into
mainfrom
bang-comment-in-rule
Sep 23, 2026
Merged

samoht merged 3 commits into
mainfrom
bang-comment-in-rule

Conversation

@samoht

@samoht samoht commented Sep 23, 2026

Copy link
Copy Markdown
Owner

A /*! */ comment inside a rule was hoisted out as a statement in front of it, so cascade diff --diff=canonical reported removed rules on the var(--tw-empty,/*!*/ /*!*/) that @tailwindcss/forms emits. It is now discarded with the rule's other comments; a /*! inside an @media block is dropped too rather than moved before the block.

A /*! */ comment in a value, a selector, an at-rule prelude or a block is hoisted out as a statement in front of the rule, so the @tailwindcss/forms output diffs against an equivalent sheet as two removed rules.
The bang-comment scan read the whole source and placed every comment that started before a rule's end in front of that rule, and a token's location began at the comments before it, so a comment inside a rule could not be told from one just before it. A token's location now starts after its leading comments, and only a comment before the next rule is kept as a statement; one inside a rule is discarded with the rule's other comments.
@samoht
samoht force-pushed the bang-comment-in-rule branch from 1fa7841 to 5c6dfa7 Compare September 23, 2026 09:09
@samoht
samoht added this pull request to stack #1278 September 23, 2026 09:09
@samoht
samoht merged commit c346075 into main Sep 23, 2026
6 checks passed
@samoht
samoht deleted the bang-comment-in-rule branch September 23, 2026 10:03
mseri pushed a commit to ocaml/opam-repository that referenced this pull request Sep 24, 2026
CHANGES:

### Parsing

- A `/*! */` comment inside a rule is discarded with the rule's other comments
  instead of being hoisted out in front of it, so `cascade diff` no longer
  reports removed rules on `@tailwindcss/forms` output (samoht/cascade#1276).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant