fix(core): honor the from clause of var() inside @container style() query values#428
Merged
Conversation
…uery values The style query collector picked up the first dashed-ident word in each group, so var(--b from './other.module.css') was collected as a local reference. Route var() found in query values through the same parsing path as declaration values so that external and global specifiers are respected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 91267d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…t node parameter Passing a callback is an uncommon pattern in this codebase and hurts readability. Instead, thread the parent postcss node (Declaration | AtRule) through the value collectors and branch on its type once in calcValueLoc. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…produces a reference A style query tests the computed value of a property rather than declaring it, so the queried dashed-ident must not become a token definition. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes token-reference extraction for var() calls that appear inside @container style(...) query values in the core parser, so var(--x from "<file>") is treated as an external reference (and from global is excluded) consistently with normal declaration-value parsing.
Changes:
- Route function parsing inside
@media/@container style()conditions through the samevar()first-argument parsing used for declaration values, enabling correctfrom "<specifier>"handling. - Generalize value-location calculation so token reference locations can be computed for both declarations and at-rule params.
- Add unit tests covering style-query
var(... from "<file>")and a style-query case where a name-defining property should still produce a reference.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/parser/dashed-ident-parser.ts | Reuses declaration-value parsing for functions in style-query values and adds at-rule-compatible location calculation to correctly emit external references for var(... from "<file>"). |
| packages/core/src/parser/dashed-ident-parser.test.ts | Adds coverage for the fixed var(... from "<file>") behavior and clarifies reference-vs-definition behavior in style queries. |
| examples/1-basic/src/a.module.css | Adds an example @container style() query using var() to help manual verification of language features. |
| .changeset/style-query-var-from-clause.md | Publishes the core fix as a patch changeset. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixes #423
Changes
Previously, a
var()with afromclause inside a@container style()query value was collected as a local token reference, ignoring thefromclause:Now
--bis treated as an external token reference to./other.module.css, the same as in a declaration value.var(--b from global)is likewise excluded from references, also matching declaration values.Test plan
vp test --project unitvp check --fix🤖 Generated with Claude Code