Skip to content

fix(compiler): omit absent color-mix weights from serialized descriptors - #464

Open
Peek-A-Booo wants to merge 1 commit into
nativewind:mainfrom
Peek-A-Booo:codex/fix-color-mix-descriptor-serialization
Open

Peek-A-Booo wants to merge 1 commit into
nativewind:mainfrom
Peek-A-Booo:codex/fix-color-mix-descriptor-serialization

Conversation

@Peek-A-Booo

Copy link
Copy Markdown

Problem

When a color-mix() weight is omitted, parseColorMix currently includes an undefined entry in its positional descriptor. Metro's JSON serialization turns that entry into null. The native resolver on main treats those optional weights as absent only when the next argument is a color or the argument list is exhausted, so it returns undefined for dynamic colors such as color-mix(in oklab, var(--card) 90%, transparent).

Change

Only emit provided percentages into the descriptor. This keeps the descriptor compact across JSON serialization and follows the native resolver's existing optional-argument consumption. The change is in source; the release build generates distributed artifacts.

Add compiler regression cases for a missing right weight, missing left weight, and both weights missing, each checking the JSON round-trip shape.

Verification

  • yarn test src/__tests__/compiler/declarations.test.tsx src/__tests__/native/color-mix.test.tsx --runInBand (24 tests pass)
  • yarn typecheck
  • yarn lint src/compiler/declarations.ts src/__tests__/compiler/declarations.test.tsx
  • yarn prettier --check src/compiler/declarations.ts src/__tests__/compiler/declarations.test.tsx

Related work

#457 fixes omitted weights in the runtime and adds color spaces. Its proposed positional destructuring assumes a five-slot descriptor; if both PRs merge, that runtime change should accept compact descriptors as well. #410 and #427 separately address shared native variable/reactivity state, so this PR does not duplicate those changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant