Repository navigation
fix(compiler): read a media query's em and rem against the font size rem inlines - #494
Open
YevheniiKotyrlo wants to merge 4 commits into
Open
YevheniiKotyrlo wants to merge 4 commits into
YevheniiKotyrlo wants to merge 4 commits into
Conversation
Both evaluators answered a range pair such as (400px < width < 800px) with false, though the compiler emits it faithfully. Media and container queries now share compareMediaFeature, so each operator has one meaning, and testMediaFeatureInterval answers a pair as its two comparisons.
…alse MQ5 §3.1 evaluates a media condition in three-valued logic: a term the runtime cannot decide is unknown, its negation is unknown, and a rule applies only when the whole condition is true. Both runtimes answered such a term false, so its negation matched: not (fictional-feature: 3) and not (pointer: fine) applied everywhere. A media feature value the compiler cannot resolve compiles to null, and both runtimes evaluate in Kleene logic, answering unknown for a null operand, a feature they do not measure, an operand they cannot order and a container style() query. A container condition holding a size feature the runtime does not know, or a value the compiler cannot resolve, selects no container (CSS Conditional 5 §5.4), so the compiler emits no rule for it. A feature in a boolean context is evaluated (MQ5 §2.4.2). The runtime answers the features whose value is the same on every React Native screen, (hover: none) no longer matches, a device with no color scheme preference matches light, and an <mq-boolean> value compiles to its integer.
…rem inlines A media query has no element, so its em and rem are both the initial font size (Media Queries 4 §1.3). The compiler kept a media bound in em as a runtime em descriptor, and with inlineRem: false one in rem as a runtime rem descriptor; the media evaluator decides neither, so (min-width: 10em) never matched, and with inlineRem: false no rem breakpoint did. Both now compile against the rem the compiler inlines, or React Native's default font size when it inlines none. The default font size was a literal 14 in four places; it is DEFAULT_REM in utilities, and the builder's unread rem field goes.
YevheniiKotyrlo
marked this pull request as ready for review
October 16, 2026 13:34
YevheniiKotyrlo
marked this pull request as draft
October 16, 2026 13:47
This was referenced Oct 16, 2026
Open
Contributor
Author
YevheniiKotyrlo
marked this pull request as ready for review
October 16, 2026 15:00
This branch has not been deployed
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.


Problem
A media query has no element, so its
emand itsremare both the initial font size (Media Queries 4 §1.3). The compiler keeps a media bound inemas a runtimeemdescriptor, and withinlineRem: falsea bound inremas a runtimeremdescriptor, and the media evaluator decides neither:(min-width: 10em)never matches, and withinlineRem: falsenorembreakpoint does - Tailwind 4'ssm:to2xl:among them.Solution
The compiler reads a media bound in
emorremagainst the rem it inlines, or React Native's default font size wheninlineRemisfalse, so the bound is a number before the evaluator sees it. Container queries keep theirem, which is the container's.That default font size was a literal
14in five places - the compiler's fallback,parseLength's default, the runtime's seed of__rn-css-rem, the runtime's defaultfontSize, and an unreadremfield on the builder - and isDEFAULT_REMinsrc/utilities/rem.tsnow; the unread field goes.Tests
src/__tests__/native/media-query-font-relative.test.tsxrenders amin-widthand amax-widthquery at each bound - inem, against an inlined rem of 16, and inemandremwithinlineRem: false- and anemrange. All six fail on #426.Verification
On Ubuntu with the workflow's steps - build, lint, typecheck,
yarn test,node --test node/__tests__/*.mjs, both library builds, the web export, the unstaged-changes checks and commitlint - everything passes.Not run: the iOS and Android example builds.
Unchanged: an
eminside acalc()in a media query is still a runtime descriptor the evaluator answers as unknown.Device evidence, before and after: #494 (comment)
Merge order
It carries #426's commits and changes the media operand parsing #426 adds, so #426 lands first.
It also shares lines with #388 (
compiler/media-query.ts,native/conditions/media-query.ts), #389 (compiler/declarations.ts,utilities/index.ts), #391 (compiler/declarations.ts,utilities/index.ts), #392 (native-internal/root.ts), #410 (native-internal/root.ts), #412 (native-internal/root.ts), #413 (compiler/declarations.ts), #415 (native/conditions/media-query.ts), #417 (compiler/declarations.ts), #420 (compiler/declarations.ts,utilities/index.ts), #425 (native/conditions/media-query.ts), #459 (compiler/compiler.types.ts,native/conditions/media-query.ts), #460 (compiler/compiler.ts), #491 (compiler/declarations.ts,utilities/index.ts), #492 (compiler/declarations.ts,utilities/index.ts), #495 (compiler/declarations.ts,utilities/index.ts); whichever lands second rebases.