fix: preserve cascading order for @container queries (#1798) - #1802
fix: preserve cascading order for @container queries (#1798)#1802hum4nBeing wants to merge 2 commits into
Conversation
|
Hi @hum4nBeing! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
4041a7e to
ea2fec1
Compare
Fixes #1798
Description
Currently,
@containerqueries do not preserve their cascading order because thelastMediaQueryWinsTransformlogic in@stylexjs/sharedstrictly looks for@mediaprefixes, completely bypassing container queries.This PR fixes the issue by:
style-value-parser): UpdatedatRuleNameParserinmedia-query.jsto accept the@containerkeyword alongside@media. (The existing range-syntax machinery already natively handles>=and<=operators).@containerinstead of rewriting to@media.shared): Extracted the sorting, negation, and range-slicing logic into a reusable helper function (applyQueryOrder) insidemedia-query-transform.js, and applied it sequentially to both@mediaand@containerquery families.By routing container queries through this deterministic pipeline, they are correctly converted into mutually exclusive ranges. This guarantees that container rules never collide, making physical CSS injection order irrelevant—which aligns perfectly with StyleX's atomic CSS architecture.
Test Plan
parse-media-query-test.jsverifying that@container (width >= 360px)successfully parses into a valid AST shape.media-query-transform-test.jsverifying that multiple container queries are correctly sorted and transformed into mutually exclusive ranges.