Skip to content

Conversation

@bartveneman
Copy link
Member

Add granular media feature parsing to match CSSTree's approach:

  • Add name property to MEDIA_FEATURE nodes (accessible via feature.name)
  • Parse feature values into typed child nodes (DIMENSION, IDENTIFIER, etc.)
  • Add FEATURE_RANGE node type (value 39) for range syntax support
  • Support modern range syntax: (50px <= width <= 100px), (width >= 400px)

Implementation:

  • Extract feature name and store in content fields
  • Parse value portion into typed AST nodes as children
  • Detect comparison operators (<=, >=, <, >, =) for range syntax
  • Add helper methods: parse_feature_value(), parse_value_token(), parse_feature_range()

BREAKING CHANGE: The .value property on MEDIA_FEATURE nodes no longer
returns the full feature string (e.g., "min-width: 768px"). Use .name
to access the feature name and .children to access parsed values.

Before:

feature.value // "min-width: 768px"

After:
feature.name // "min-width"
feature.children[0].type // DIMENSION
feature.children[0].text // "768px"

@bartveneman bartveneman changed the title parse media feature names and values into structured nodes breaking: parse media feature names and values into structured nodes Jan 1, 2026
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 94.56522% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.07%. Comparing base (27df82c) to head (5862450).

Files with missing lines Patch % Lines
src/parse-atrule-prelude.ts 94.44% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #95      +/-   ##
==========================================
- Coverage   95.10%   95.07%   -0.03%     
==========================================
  Files          15       15              
  Lines        2471     2559      +88     
  Branches      636      662      +26     
==========================================
+ Hits         2350     2433      +83     
- Misses        121      126       +5     

☔ 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.

@bartveneman bartveneman merged commit 93dd619 into main Jan 1, 2026
5 checks passed
@bartveneman bartveneman deleted the parse-media-feature-range branch January 1, 2026 23:09
@codecov-commenter
Copy link

Bundle Report

Changes will increase total bundle size by 4.7kB (3.53%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@projectwallace/css-parser-esm 137.91kB 4.7kB (3.53%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: @projectwallace/css-parser-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
parse-*.js 4.5kB 22.0kB 25.73% ⚠️
css-*.js 55 bytes 16.73kB 0.33%
arena.js 41 bytes 10.74kB 0.38%
string-*.js 43 bytes 3.32kB 1.31%
constants.js 47 bytes 2.01kB 2.4%
index.js 15 bytes 1.79kB 0.84%

Files in parse-*.js:

  • ./src/parse-atrule-prelude.ts → Total Size: 21.24kB

Files in css-*.js:

  • ./src/css-node.ts → Total Size: 15.89kB

Files in arena.js:

  • ./src/arena.ts → Total Size: 9.84kB

Files in string-*.js:

  • ./src/string-utils.ts → Total Size: 2.88kB

Files in constants.js:

  • ./src/constants.ts → Total Size: 672 bytes

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.

3 participants