fix(compiler): omit absent color-mix weights from serialized descriptors - #464
Open
Peek-A-Booo wants to merge 1 commit into
Open
Peek-A-Booo wants to merge 1 commit into
Peek-A-Booo wants to merge 1 commit into
Conversation
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
When a
color-mix()weight is omitted,parseColorMixcurrently includes anundefinedentry in its positional descriptor. Metro's JSON serialization turns that entry intonull. The native resolver onmaintreats those optional weights as absent only when the next argument is a color or the argument list is exhausted, so it returnsundefinedfor dynamic colors such ascolor-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 typecheckyarn lint src/compiler/declarations.ts src/__tests__/compiler/declarations.test.tsxyarn prettier --check src/compiler/declarations.ts src/__tests__/compiler/declarations.test.tsxRelated 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.