Skip to content

Ignore undefined style values on native#498

Open
adityasingh2400 wants to merge 1 commit into
react:mainfrom
adityasingh2400:fix/ignore-undefined-style-values
Open

Ignore undefined style values on native#498
adityasingh2400 wants to merge 1 commit into
react:mainfrom
adityasingh2400:fix/ignore-undefined-style-values

Conversation

@adityasingh2400

Copy link
Copy Markdown

Fixes #452

On native, returning undefined for a property from an inline style function (or any style object with an undefined value) leaks that key through processStyle and into the style resolver, which throws styleq: <cssAtom> typeof undefined is not "string" or "null". This is a regression; these values used to be dropped, and on web undefined values are simply ignored.

The loop in processStyle branches on object/string/number, so an undefined value falls through to the catch-all assignment and ends up in the result as { rowGap: undefined }. This adds an early continue for undefined values so the property is omitted, matching web behavior and letting inline style functions return undefined to opt out of a property.

null is left untouched since the resolver accepts it.

Testing: added a regression test under css.create() > values: general that asserts the property is absent when the inline function returns undefined. Confirmed it fails on main and passes with the fix. Full native + web jest suites pass (888 tests, 711 snapshots unchanged), Flow and ESLint clean.


Reopening this. I closed it by accident during a bulk cleanup of my stale forks and cannot reopen the original because the fork was deleted, so this is the same branch restored. Sorry for the noise @MoOx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

styleq: <cssAtom> typeof undefined is not "string" or "null".

1 participant