fix(issue#4356): parenthesis in media query#4427
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe changes enhance media feature parsing in the LESS parser with more robust closing parenthesis tracking using a local closed flag, and introduce corresponding test cases for complex nested media query conditions combining color and hover states. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip You can get early access to new features in CodeRabbit.Enable the |
There was a problem hiding this comment.
Pull request overview
Fixes Less media query parsing to support valid CSS that includes nested parentheses in media conditions (issue #4356), and adds a regression test to ensure the behavior stays supported.
Changes:
- Adjusted
mediaFeatureparsing to correctly handle a parenthesized value that itself contains parentheses (e.g.((color) and (hover))). - Added a new unit test input and expected CSS output covering the reported nested-parens media query case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/test-data/tests-unit/media/media.less | Adds a regression test case exercising nested parentheses in @media conditions. |
| packages/test-data/tests-unit/media/media.css | Adds the expected compiled output for the new nested-parentheses @media test. |
| packages/less/lib/less/parser/parser.js | Updates media query feature parsing to accept nested parentheses by attempting value() parsing and falling back to recursive mediaFeature() parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What:
Why:
This Less:
results in
Parsing error, missing closing ')',The syntax is valid CSS so it should be supported. (Per: https://jigsaw.w3.org/css-validator/validator)
Checklist:
Summary by CodeRabbit
Bug Fixes
Tests