Skip to content

Support nested at-rules in @font-feature-values and @page - #316

Merged
bartveneman merged 3 commits into
mainfrom
claude/sharp-faraday-8fnhix
Oct 21, 2026
Merged

bartveneman merged 3 commits into
mainfrom
claude/sharp-faraday-8fnhix

Conversation

@bartveneman

Copy link
Copy Markdown
Member

Summary

This PR updates the CSS parser to correctly handle nested at-rules within @font-feature-values and @page blocks, rather than treating their contents as declarations only.

Key Changes

  • Updated DECLARATION_AT_RULES set: Removed font-feature-values and page from the set of at-rules that only contain declarations, allowing them to have nested at-rules as children
  • Added feature-specific at-rules: Added all CSS feature value descriptors (styleset, stylistic, character-variant, swash, ornaments, annotation) to DECLARATION_AT_RULES since these are nested within @font-feature-values and contain only declarations
  • Added page margin at-rules: Added all CSS page margin box at-rules (top-left-corner, top-left, top-center, etc.) to DECLARATION_AT_RULES since these are nested within @page and contain only declarations
  • Added comprehensive test coverage: Added two new test cases validating:
    • @font-feature-values with nested @styleset and @swash at-rules
    • @page with mixed declarations and nested margin at-rules (@top-left, @bottom-right-corner)

Implementation Details

The parser now correctly distinguishes between at-rules that can contain nested at-rules (@font-feature-values, @page) and at-rules that only contain declarations (the feature descriptors and margin boxes). This allows proper AST construction for these CSS constructs while maintaining backward compatibility with existing parsing logic.

https://claude.ai/code/session_01BDQgvjjtLygov1cCyBRKTc

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Package Size Increase

📦 Package 📏 Base Size 📏 Source Size 📈 Size Change
@projectwallace/css-parser 47 kB 47.1 kB +111 B

@pkg-pr-new

pkg-pr-new Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@projectwallace/css-parser@58772c0

commit: 58772c0

@bartveneman
bartveneman merged commit 0c9c576 into main Oct 21, 2026
16 checks passed
@bartveneman
bartveneman deleted the claude/sharp-faraday-8fnhix branch October 21, 2026 12:13
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.

2 participants