Repository navigation
fix(compiler): omit absent color-mix weights from serialized descriptors - #579
Merged
danstepanov merged 4 commits intoNov 20, 2026
Merged
Conversation
Keep only the compiler-side fix, written as a filter on the existing argument list, and the serialized-injection regression test. Drop the runtime null branch: with the compiler no longer emitting holes it was unreachable for fresh builds, and it let the regression test pass whether or not the compiler fix was present. Drop the compiler test that asserted on the internal stylesheet layout; the end-to-end test covers the same cases through Metro's JSON path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D4jU1dT613ZBytY8eaFjgE
danstepanov
approved these changes
Nov 20, 2026
This was referenced Nov 20, 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.
Supersedes #464 and #511, keeping both authors' commits, with the following modifications:
.filteron the existing argument list instead of rebuilding the list withpushnullbranch: once the compiler emits no holes, fresh builds can't reach it. With both fixes in place, the regression test passed even after either one was reverted, so it couldn't catch a revert of the compiler fix.stylesheet.s?.[0]?.[1]?.[0]?.d). The end-to-end test covers the same three cases through Metro's JSON path.Fixes #481, nativewind/nativewind#1870.
Problem
Tailwind 4 compiles an opacity modifier on a CSS-variable color (
bg-brand/10,text-white/50) to acolor-mix()with a single weight:parseColorMixemitted its arguments in five fixed slots,[space, left, left%, right, right%], and leftundefinedin the slot for an omitted weight. Metro'sgetNativeInjectionCodeserializes the stylesheet withJSON.stringify, which turns thatundefinedintonull. The native resolver doesn't consume anullweight, so it rejects the whole value and the element renders with no color. This is a regression from 3.0.7, introduced when #451 made the resolver stricter.Either weight can be the omitted one:
mainon nativecolor-mix(in oklab, var(--white) 50%, transparent)rgba(255, 255, 255, 0.5)color-mix(in oklab, var(--white), transparent 75%)rgba(255, 255, 255, 0.25)color-mix(in oklab, var(--white), transparent)rgba(255, 255, 255, 0.5)Existing tests didn't catch this.
registerCSSinjects the stylesheet object directly, without serializing it, andresolveValuefiltersundefinedout of descriptor arrays.Solution
parseColorMixemits only the arguments that are present, so there's no hole left to serialize. The argument order is unchanged, and the resolver (color-mix.ts) already handles a missing optional weight when the next argument is a color or the list ends.The filter runs once per
color-mix()at compile time. Nothing is added to the runtime path, and the serialized output is slightly smaller.Tests
src/__tests__/native/color-mix.test.tsx(3 cases, from #511). Each case compiles real CSS withinlineVariables: false, round-trips the stylesheet throughJSON.parse(JSON.stringify(...))the same way Metro's injection does, injects it withStyleCollection.inject, and renders aView. The cases are left weight only, right weight only, and neither weight.mainand pass with the fix..filterfails all 3.#511's author also reproduced the bug in a physical Android release build on 3.1.0-rc.0.
Not included
nullweights. Clearing the Metro cache fixes that. If we want the runtime to handle it anyway, fix: preserve omitted color-mix weights in serialized native styles #511'snullbranch can come back as its own commit, with a test that builds descriptors by hand instead of going through the compiler.