Skip to content

Fix CSS @media query parsing error in style elements#119

Merged
swhitty merged 1 commit into
swhitty:mainfrom
rursache:fix/59-media-query-parsing
Apr 22, 2026
Merged

Fix CSS @media query parsing error in style elements#119
swhitty merged 1 commit into
swhitty:mainfrom
rursache:fix/59-media-query-parsing

Conversation

@rursache
Copy link
Copy Markdown
Contributor

Summary

  • Skip unknown CSS @ rules (e.g. @media, @supports) including nested blocks when parsing style sheets
  • Previously the parser would fail when encountering @media queries, printing a parsing error to console
  • The scanner now tracks brace depth to correctly skip over nested rule blocks while continuing to parse surrounding selectors

Test plan

  • Added skipsMediaQueries() test verifying @media blocks are skipped and surrounding selectors are parsed
  • Added skipsNestedAtRules() test verifying doubly-nested @ rules (e.g. @supports containing @media) are skipped
  • All 195 tests pass

Closes #59

Skip unknown CSS @ rules (e.g. @media, @supports) including nested
blocks when parsing style sheets. Previously the parser would fail
when encountering @media queries, printing a parsing error to console.

The scanner now tracks brace depth to correctly skip over nested rule
blocks while continuing to parse surrounding selectors.

Closes #59
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.43%. Comparing base (6238058) to head (ed1d5a7).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
+ Coverage   89.02%   89.43%   +0.41%     
==========================================
  Files         159      159              
  Lines       11959    15445    +3486     
==========================================
+ Hits        10646    13814    +3168     
- Misses       1313     1631     +318     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@swhitty
Copy link
Copy Markdown
Owner

swhitty commented Apr 22, 2026

thank you

@swhitty swhitty merged commit 3fb710c into swhitty:main Apr 22, 2026
11 checks passed
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.

Parsing Error

2 participants