Repository navigation
fix: keep function values whole in media range syntax and split bare = comparator - #317
Merged
Merged
Conversation
…= 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.
Contributor
|
| 📦 Package | 📏 Base Size | 📏 Source Size | 📈 Size Change |
|---|---|---|---|
| @projectwallace/css-parser | 47.1 kB | 47.1 kB | +33 B |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes in
parse_feature_range(src/parse-condition.ts):(width >= calc(1px + 2px))produced aFunctionnode with textcalc(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.FeatureRangechildren are now typedDimension | Function | PreludeOperator, since a range can contain a function value.Test plan
=, and<=/>=pnpm exec vitest run,pnpm run lint,pnpm run check,pnpm knipGenerated by Claude Code