fix: preserve exclusive native media query bounds - #675
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change preserves ChangesMedia-query width bounds
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Native width media queries now correctly distinguish strict and inclusive bounds, including fractional widths, with regression coverage for boundary resolution and viewport-change updates. No current merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR preserves exclusive native width-query semantics throughout compilation and runtime resolution.
Confidence Score: 5/5The PR appears safe to merge; the compiler metadata, runtime matching, dependency invalidation, and regression coverage are aligned. No actionable failure remains after tracing exclusive bounds from parsing through generated metadata, native resolution, and dimension-driven cache invalidation.
|
| Filename | Overview |
|---|---|
| packages/uniwind/src/bundler/css-processor/mq.ts | Preserves the distinction between strict and inclusive width comparison operators while initializing safe defaults. |
| packages/uniwind/src/bundler/css-processor/addMetaToStylesTemplate.ts | Serializes exclusivity metadata and records dimension dependencies for every exclusive bound. |
| packages/uniwind/src/core/native/store.ts | Rejects viewport equality when the corresponding compiled width bound is exclusive. |
| packages/uniwind/tests/native/styles-parsing/media-queries.test.ts | Adds native end-to-end regression coverage across platforms, comparison operators, fractional boundaries, and cache invalidation. |
| packages/uniwind/src/core/types.ts | Aligns the internal runtime Style contract with the newly generated bound metadata. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[CSS width query] --> B[Parse numeric bound and operator]
B --> C[Emit min/max width plus exclusivity flag]
C --> D[Record Dimensions dependency]
C --> E[Native style store]
E --> F{Viewport satisfies bound?}
F -->|Yes| G[Apply native style]
F -->|Equality at exclusive bound| H[Reject native style]
I[Viewport change] --> J[Dimensions notification]
J --> K[Invalidate cached result]
K --> E
Reviews (1): Last reviewed commit: "fix: preserve exclusive native media que..." | Re-trigger Greptile
Fixes #674.
At exactly 402 points,
(width > 402px)and(width < 402px)both incorrectly applied their native styles. The compiler discarded the distinction between exclusive and inclusive operators, and the native resolver treated every bound inclusively.Preserve exclusivity as metadata alongside each width bound and reject equality for exclusive bounds during native resolution. Bounds retain their original values, including fractions. Exclusive bounds also register dimension dependencies, including
width > 0px, so cached styles update when the viewport changes.Regression coverage
The tests compile CSS into native JavaScript artifacts for iOS and Android and resolve them through the real native style store. They verify padding below, at, and above both 402pt and 402.5pt boundaries for
>,>=,<, and<=, using quarter-point viewport steps. The eight exclusive comparison cases failed before the fix and pass afterward. Additional cases preserve legacymin-width/max-widthinclusivity and verify cache invalidation across an exclusive zero bound.All 22 focused cases, 193 native tests, and 30 web tests pass. Package build, source/test/public type checks, lint, formatting, and circular dependency checks also pass. Device UI and browser E2E tests were not run.
Summary by CodeRabbit
Bug Fixes
>and<width comparisons.Tests
Documentation