Skip to content

fix: keep function values whole in media range syntax and split bare = comparator - #317

Merged
bartveneman merged 2 commits into
mainfrom
claude/bold-turing-1r8xcf
Oct 21, 2026
Merged

bartveneman merged 2 commits into
mainfrom
claude/bold-turing-1r8xcf

Conversation

@bartveneman

Copy link
Copy Markdown
Member

Summary

Two fixes in parse_feature_range (src/parse-condition.ts):

  • Function values in range syntax were truncated. (width >= calc(1px + 2px)) produced a Function node with text calc( and a null value, and the arguments leaked out as siblings of the range. Anything slicing the source from these offsets, or trusting .text, got unbalanced parentheses. The function token is now consumed through its matching ) and parsed as a whole value, as the non-range form already does. Also affects (calc(1px) < width < 5px).
  • => is now tokenized consistently. Only < and > absorb a following =, so <= and >= stay single comparators and a bare = stands alone. Previously == joined into one token while => split, which was inconsistent. => is not valid Media Queries syntax; it now yields = then > on purpose, and a test pins that.

FeatureRange children are now typed Dimension | Function | PreludeOperator, since a range can contain a function value.

Test plan

  • New tests for function values in trailing and leading position, bare =, and <=/>=
  • The two function tests fail without the fix
  • pnpm exec vitest run, pnpm run lint, pnpm run check, pnpm knip

Generated by Claude Code

…= comparator

parse_feature_range stopped at the function token, so calc(1px) in
(width >= calc(1px)) became a Function with text 'calc(' and its
arguments leaked out as siblings. It now consumes through the matching
paren. A bare '=' is also its own comparator now, so '=>' is '=' then '>'
consistently regardless of operand order.
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Package Size Increase

📦 Package 📏 Base Size 📏 Source Size 📈 Size Change
@projectwallace/css-parser 47.1 kB 47.1 kB +33 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@feec23d

commit: feec23d

@bartveneman
bartveneman merged commit c5257a8 into main Oct 21, 2026
16 checks passed
@bartveneman
bartveneman deleted the claude/bold-turing-1r8xcf branch October 21, 2026 14:18
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