Repository navigation
fix(compiler): list a stylesheet's variables in the same order on every read - #476
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
…ry read getNativeStyleSheet reversed each root and universal variable list in place to put the most specific value first. Reading the stylesheet again reversed the lists back, so a second read listed the unconditioned value first, and the first sheet's lists changed under it. The lists are now reversed into a copy.
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
getNativeStyleSheetreverses each root and universal variable list in place to put the most specific value first. Reading the stylesheet a second time reverses the lists back. Measured onmain:The second read lists the unconditioned value first, so the dark value never wins, and the first sheet's lists change under it because both reads hand out the builder's own arrays. The same holds for
vu.Solution
Both lists are reversed into a copy with
toReversed(), so every read of a stylesheet is the same and a sheet already handed out stays as it was.Tests
src/__tests__/compiler/compiler.test.tsx: reading the stylesheet twice gives the samevrandvu, most specific value first, and leaves the first read unchanged.main, the new case fails at the second read and the other 14 in the file pass. Restoring the in-place reverse on either list fails it, and dropping the reverse altogether also fails:root CSS variables with media queries.Verification
On Windows with Node 26:
yarn lintcleanyarn typecheckcleanyarn test --coverage: every failure also fails onmainon this machine (the four babel cases)yarn buildcleanyarn example expo export --platform webexportedNo existing issue tracks this. I searched for
getNativeStyleSheet,rootVariables reverseandvariables order media.Base
Branched off
main(a5002c5).