fix: Builder parser does not strip falsey style values #1697
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.
Description
The Builder JSON parser currently strips out falsey style values (I.e.
padding: 0
). The original motivation for this was to cut down on the amount of CSS generated with codegen in Builder. However, our codegen process has improved since then where this is not a big problem anymore.More importantly, stripping falsey values is causing functional changes to the code because we make the assumption that a value of
0
is the same as not having the CSS declaration to begin with which is not always true. For example, we remove values such asflex-shrink: 0
. However, the default value forflex-shrink
is 1.Another example can be seen here: https://codepen.io/liamdebeasi/pen/gbOrgJm
In the first block
#text
hasz-index: 0
which causes it to show on top of the square. In the second block ,#text
does not havez-index: 0
which causes it to show below the square.This PR resolves the issue by removing logic that removes falsey CSS values.
For added context, this logic was originally added via a PR to Mitosis, but this PR was a port from another repo.
Make sure to follow the PR preparation steps in CONTRIBUTING.md before submitting your PR:
yarn fmt:prettier
.yarn test:update
yarn g:changeset
and follow the CLI instructions. Alternatively, use the Changeset Github Bot to create the file.