Skip to content

Conversation

@bartveneman
Copy link
Member

breaking: make AtRule.prelude return CSSNode instead of string

Changes the .prelude getter on at-rule nodes to return CSSNode | null
instead of string | null, matching CSSTree's API and enabling traversal
of structured prelude children (media queries, layer names, etc.).

BREAKING CHANGES:

  • AtRule.prelude now returns CSSNode | null instead of string | null
  • Use .prelude.text to get the text representation
  • Use .value for raw string when prelude parsing is disabled or unsupported
  • At-rules without structured prelude parsing return null
  • clone() no longer extracts prelude as a property (now part of children)

Implementation:

  • Added AT_RULE_PRELUDE (40) wrapper node type
  • Parser wraps parsed prelude nodes before adding to at-rule children
  • Updated prelude getter to return AT_RULE_PRELUDE node or null
  • Exported AT_RULE_PRELUDE constant via constants.ts
  • Updated all 1107 tests to use new API

Benefits:

  • Enables walking prelude children like CSSTree
  • Provides structured access to media queries, layer names, etc.
  • Maintains text access via .prelude.text
  • Preserves arena efficiency (one wrapper per at-rule)

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.5 [email protected]

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 84.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.99%. Comparing base (599f11a) to head (f182c86).

Files with missing lines Patch % Lines
src/parse.ts 77.77% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #107      +/-   ##
==========================================
- Coverage   95.12%   94.99%   -0.13%     
==========================================
  Files          15       15              
  Lines        2583     2598      +15     
  Branches      669      674       +5     
==========================================
+ Hits         2457     2468      +11     
- Misses        126      130       +4     

☔ 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 38bf8e5 into main Jan 3, 2026
5 checks passed
@bartveneman bartveneman deleted the atrule-prelude-node branch January 3, 2026 16:27
@codecov-commenter
Copy link

Bundle Report

Changes will increase total bundle size by 987 bytes (0.71%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@projectwallace/css-parser-esm 140.57kB 987 bytes (0.71%) ⬆️

Affected Assets, Files, and Routes:

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

Assets Changed:

Asset Name Size Change Total Size Change (%)
css-*.js 93 bytes 16.64kB 0.56%
parse.js 779 bytes 13.17kB 6.29% ⚠️
arena.js 45 bytes 10.96kB 0.41%
constants.js 53 bytes 2.08kB 2.61%
index.js 17 bytes 1.82kB 0.94%

Files in css-*.js:

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

Files in parse.js:

  • ./src/parse.ts → Total Size: 12.31kB

Files in arena.js:

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

Files in constants.js:

  • ./src/constants.ts → Total Size: 700 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