Repository navigation
fix(native): let a rule's shadow list replace an earlier rule's - #488
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
A compiled box-shadow is written index by index, and the walk reused the list an earlier rule had already written for the element. A later rule's list therefore merged into it: `[green]` over `[red, blue]` rendered `[green, blue]`, and an outset shadow over an inset one kept `inset: true`. The same CSS resolved at runtime, through a variable, already replaced the list. Each rule's first write to a list now starts a new one.
Contributor
Author
YevheniiKotyrlo
marked this pull request as ready for review
October 16, 2026 10:02
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 compiled
box-shadowis written one entry at a time (&.boxShadow.[0].color,&.boxShadow.[0].offsetX, …), and the walk wrote into whatever list the element already held, so a later rule's list merged into an earlier rule's instead of replacing it:className="first second"renders two shadows,#13579band#654321, where a browser renders#13579balone. An outset shadow over an inset one keepsinset: true, and the same happens between two!importantlists and across specificity. The same CSS resolved at runtime, through a variable that is not inlined, already replaced the list, so the result depended on whether the compiler had inlined the variable.Solution
applyDeclarationsruns once per rule. It now remembers the lists that rule starts, and the rule's first write to any other list replaces it with a new one.Tests
src/__tests__/native/box-shadow.test.tsx: ten cascades — a list over a longer one, over an inset shadow and over one held in a variable; a list held in a variable over a literal one and over another;noneover a list and a list overnone; an!importantlist over an earlier important one and under a later normal one; and a more specific list over a later one — each run with variables inlined and resolved at runtime, and with the sheet injected as compiled and as the JSON a device receives. Each expected value is what Chromium 153, Firefox 155 and WebKit 26.6 compute for the same CSS. Onmain22 of the 40 fail: every case that writes a compiled list over a list an earlier rule wrote. The other 18 — a list resolved at runtime,none, and an important list under a later normal one — pass before and after.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.Device evidence, before and after: #488 (comment)
Not run: the iOS and Android example builds.
Merge order
It shares lines with #391 (
native/styles/calculate-props.ts), #393 (native/styles/calculate-props.ts), #474 (native/styles/calculate-props.ts); whichever lands second rebases.