Skip to content

feat: add support for @function at-rule#168

Merged
bartveneman merged 3 commits intomainfrom
feat/support-at-function
Mar 10, 2026
Merged

feat: add support for @function at-rule#168
bartveneman merged 3 commits intomainfrom
feat/support-at-function

Conversation

@bartveneman
Copy link
Member

Parses the CSS @function at-rule (https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@function).

The @function body is treated as a conditional block (like @media), allowing both declarations and nested at-rules such as @media inside the function body. The prelude is parsed to extract the function name as an IDENTIFIER node.

Usage:

  const ast = parse('@function --transparent(--color, --alpha) { result: oklch(...); }')
  const fn = ast.first_child
  fn.name                      // 'function'
  fn.value                     // '--transparent(--color, --alpha)' (raw prelude)
  fn.prelude.first_child.text  // '--transparent' (function name as IDENTIFIER)
  fn.block.children            // [DECLARATION result: ...]

bartveneman and others added 2 commits March 10, 2026 09:20
Parses the CSS @function at-rule (https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@function).

The @function body is treated as a conditional block (like @media), allowing
both declarations and nested at-rules such as @media inside the function body.
The prelude is parsed to extract the function name as an IDENTIFIER node.

Usage:

  const ast = parse('@function --transparent(--color, --alpha) { result: oklch(...); }')
  const fn = ast.first_child
  fn.name                      // 'function'
  fn.value                     // '--transparent(--color, --alpha)' (raw prelude)
  fn.prelude.first_child.text  // '--transparent' (function name as IDENTIFIER)
  fn.block.children            // [DECLARATION result: ...]

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.97%. Comparing base (42d04c6) to head (9041f24).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #168      +/-   ##
==========================================
+ Coverage   94.96%   94.97%   +0.01%     
==========================================
  Files          16       16              
  Lines        2877     2887      +10     
  Branches      804      807       +3     
==========================================
+ Hits         2732     2742      +10     
  Misses        145      145              

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

@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2026

Bundle Report

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

Detailed changes
Bundle name Size Change
@projectwallace/css-parser-esm 159.49kB 423 bytes (0.27%) ⬆️

Affected Assets, Files, and Routes:

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

Assets Changed:

Asset Name Size Change Total Size Change (%)
parse-atrule-prelude.js 376 bytes 21.05kB 1.82%
parse.js 13 bytes 10.57kB 0.12%
parse-atrule-prelude.d.ts 34 bytes 1.65kB 2.1%

Files in parse-atrule-prelude.js:

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

Files in parse.js:

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

@bartveneman bartveneman merged commit 796e0cb into main Mar 10, 2026
4 checks passed
@bartveneman bartveneman deleted the feat/support-at-function branch March 10, 2026 08:31
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