fix(preset-mini,preset-wind4): key the breakpoint cache by kind - #5303
Merged
Merged
Conversation
✅ Deploy Preview for unocss ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
commit: |
resolveBreakpoints memoized into a WeakMap keyed only on the theme object, while the function also takes a key selecting breakpoints or verticalBreakpoints. The breakpoints variant resolves the horizontal set for every token during variant matching, which always runs before rule matching, so the cache was already populated by the time h-screen-* asked for the vertical set and it received the horizontal values instead. The defaults make verticalBreakpoints a copy of breakpoints, so this is only visible once the two are customized differently. The cache is now a Map keyed by the breakpoint kind.
rajanpanth
force-pushed
the
fix/vertical-breakpoints-cache-key
branch
from
September 4, 2026 15:01
d69e497 to
4e1abc6
Compare
zyyv
approved these changes
Sep 5, 2026
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.
Description
resolveBreakpointstakes akeyselectingbreakpointsorverticalBreakpoints, but memoizes into aWeakMapkeyed only on the theme object:The
breakpointsvariant calls it with the default horizontal key for every token during variant matching, and variant matching always runs before rule matching. So by the timeh-screen-<point>asks for the vertical set, the entry is already populated with the horizontal one and the vertical values are silently ignored.Isolated, on one theme:
End to end, with
verticalBreakpoints: { sm: '400px', md: '500px' }:This is deterministic rather than order-dependent, and it stays hidden with the shipped defaults because
verticalBreakpointsstarts as a copy ofbreakpoints. It only surfaces once a user customizes them differently, which theh-screen-$verticalBreakpointsautocomplete and the typed theme key both invite.Change
The cache becomes a
Mapkeyed by the breakpoint kind, so the two sets no longer share an entry. Applied identically topreset-miniandpreset-wind4, which carry the same function.Tests
One test per preset, asserting
h-screen-sm/mdfollow the vertical set whilew-screen-smstill follows the horizontal one, so an over-correction that swapped both would also fail.Reverting only the two source files and rebuilding the presets fails both with
.h-screen-md{height:768px;}against the expected500px; restoring passes. Fullpreset-miniandpreset-wind4suites pass 46/46, and eslint is clean on the changed files.