Skip to content

fix(parser): accept scroll-state(...) in @container not queries#8855

Merged
ematipico merged 5 commits intobiomejs:mainfrom
ruidosujeira:fix/8840-container-not-scroll-state
Feb 18, 2026
Merged

fix(parser): accept scroll-state(...) in @container not queries#8855
ematipico merged 5 commits intobiomejs:mainfrom
ruidosujeira:fix/8840-container-not-scroll-state

Conversation

@ruidosujeira
Copy link
Contributor

Summary

Fixes container query parsing to accept not combined with function-style queries like scroll-state(...), matching browser behavior and avoiding parser errors in @container conditions.

Fixes #8840.

Test Plan

always cargo test -p biome_css_parser --test spec_tests at_rule_container

Docs

No docs changes (parser/grammar update only).

@changeset-bot
Copy link

changeset-bot bot commented Jan 24, 2026

🦋 Changeset detected

Latest commit: ead8c38

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools L-CSS Language: CSS labels Jan 24, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds support for general-enclosed values inside container-query parentheses by extending the grammar union AnyCssContainerQueryInParens with an AnyCssValue alternative. The parser now recognises function-form queries (identifier followed by '(') and includes new predicates and handlers to parse scroll-state(...) via parse_any_value. The CSS formatter receives a new match arm to format AnyCssValue. Three parser tests covering not/grouping with scroll-state(...) were added and a changeset records the fix for the related issue.

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarises the main change: accepting scroll-state(...) in @container not queries, which directly matches the changeset's parser fixes.
Description check ✅ Passed The description is well-related to the changeset, explaining the parser fix for container queries with negation and scroll-state functions, referencing issue #8840.
Linked Issues check ✅ Passed The PR successfully addresses issue #8840 by enabling the parser to accept 'not scroll-state(...)' and similar negated function-style queries in @container conditions, with added test coverage for the three reported forms.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to the container query parsing issue: grammar updates, parser logic, formatter support, and test cases—no unrelated modifications detected.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 24, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 127 skipped benchmarks1


Comparing ruidosujeira:fix/8840-container-not-scroll-state (ead8c38) with main (086a0c5)

Open in CodSpeed

Footnotes

  1. 127 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@ruidosujeira ruidosujeira changed the title fix/ Parser error when combining not and scroll-state in @container query fix(parser): accept scroll-state(...) in @container not queries Jan 24, 2026
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the changes aren't correct because we're now parsing incorrect syntax as correct

Comment on lines 742 to 755
> 22 │ @container (width > 300px) and and (height > 200px) {
│ ^^^
^^^^^^^
23 │ }
24 │

i Expected one of:

- ( <container-query> )
- ( <size-feature> )
- style( <style-query> )
- identifier
- string
- number
- dimension
- ratio
- custom property
- function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a regression. We're now parsing a double and and

Comment on lines 666 to 669
2: CSS_BOGUS@566..580
0: CSS_BOGUS@566..580
0: CSS_BOGUS@566..580
0: CSS_BOGUS@566..580
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We went from 2 bogus nodes to 4 bogus nodes. It seems we worsened the already brittle recovering

@ruidosujeira
Copy link
Contributor Author

Restricted container-query function parsing to scroll-state(...) only and removed the generic parse_any_value fallback.
This restores proper diagnostics for invalid chains like and and / or or and improves recovery.

All at_rule_container tests are passing.

"@biomejs/biome": patch
---

Fixed [#8840](https://github.com/biomejs/biome/issues/8840). Now the Biome CSS parser correctly parses `not + scroll-state` inside `@container` queries.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Fixed [#8840](https://github.com/biomejs/biome/issues/8840). Now the Biome CSS parser correctly parses `not + scroll-state` inside `@container` queries.
Fixed [#8840](https://github.com/biomejs/biome/issues/8840). Now the Biome CSS parser correctly parses `not + scroll-state` inside `@container` queries.

@ematipico
Copy link
Member

@ruidosujeira can you please fix the conflict?

@ruidosujeira ruidosujeira force-pushed the fix/8840-container-not-scroll-state branch from 4bc93a8 to e66c941 Compare February 18, 2026 17:39
@ruidosujeira
Copy link
Contributor Author

@ematipico I managed to resolve the conflicts.

@ematipico ematipico merged commit 6918c9e into biomejs:main Feb 18, 2026
17 checks passed
@github-actions github-actions bot mentioned this pull request Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: internal tools L-CSS Language: CSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Parser error when combining not and scroll-state in @container query

2 participants