Fix incorrect background-clip style after color:linear-gradient removed #1183
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: linear-gradient(...)
style is removed and replaced with a normal color, the transform function incorrectly setsbackground-clip: initial
and-webkit-background-clip: initial
. This causes background colors to not display properly because the default value forbackground-clip
should beborder-box
, notinitial
.Root Cause
In
transformLynxStyles.ts
, thevalueProcessor
functions forbackground-clip
and-webkit-background-clip
were returning'initial'
for non-gradient colors:This affected elements like:
Solution
Changed the
valueProcessor
functions to return'border-box'
(the CSS default) instead of'initial'
when the color value doesn't contain 'gradient':This ensures that:
background-clip: text
)background-clip: border-box
)Testing
style-background-color.html
andbackground-color-inherit.html
) work correctlyThe screenshot shows the fix working correctly - elements with normal colors now properly display their background colors.
Files Changed
packages/web-platform/web-style-transformer/src/transformLynxStyles.ts
: Fixed background-clip reset logicpackages/web-platform/web-style-transformer/src/__tests__/transformLynxStyles.test.js
: Added comprehensive test coverageFixes #1165.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.