Skip to content

Fix comma operator discarding shadow/textShadow options in preprocess - #2915

Open
charan-rathore wants to merge 2 commits into
necolas:masterfrom
charan-rathore:patch-1
Open

charan-rathore wants to merge 2 commits into
necolas:masterfrom
charan-rathore:patch-1

Conversation

@charan-rathore

Copy link
Copy Markdown

Problem

The two shadow guards in StyleSheet/preprocess.js use the comma operator:

if (
  (options.shadow === true,
  style.shadowColor != null || ...)
)

so options.shadow / options.textShadow are evaluated and discarded. The shadow* to boxShadow and textShadow* to textShadow conversions run whenever the legacy props are present, even when the caller explicitly disables them through the StyleSheet options (customStyleq forwards { shadow: false, textShadow: false }).

Fix

Use && as intended, matching how StyleSheet/index.js opts in with defaultPreprocessOptions = { shadow: true, textShadow: true }. The existing shadow tests now pass that option explicitly (they previously relied on the comma bug), and new tests cover the disabled path: no options, or { shadow: false } / { textShadow: false }, leaves the legacy props unconverted.

Fixes #2914

Tests

  • New disabled-path tests fail before the fix and pass after it.
  • jest packages/react-native-web/src/exports/StyleSheet: 91 passed, 51 snapshots.

Prepared with AI assistance (Instinct assisted).

The two guards in StyleSheet/preprocess used the comma operator, so options.shadow and options.textShadow were evaluated and discarded: the shadow* to boxShadow and textShadow* to textShadow conversions ran whenever the legacy props were present, even when the caller disabled them through StyleSheet options.

Use && as intended and cover the disabled path with tests.

Fixes necolas#2914

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 003f74a:

Sandbox Source
react-native-web-examples Configuration

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.

preprocess.js: broken if queries

1 participant