-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: usage of styles in a loop and non-existent styles #527
Conversation
compressed-size: runtime library Size change: 0.00 kB View unchanged
|
compressed-size: e2e bundles Size change: 0.00 kB View unchanged
|
import stylex from '@stylexjs/stylex'; | ||
function test(colors, obj) { | ||
for (const color of colors) { | ||
obj[color.key] = stylex(color.style); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there already a test for this against the stylex.props
syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add it. For now I was testing the specific code that caused a breakage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it's worth testing everything against the main syntax first. Tests against the legacy syntax are only relevant for Meta.
Found and fixed a bug in the optimisation step for optimising
stylex.props()
andstylex()
calls within afor-of
loop.The custom
evaluate
logic would fail to bail out and throw a null pointer exception instead.The fix was to check for that null value and bail out instead.
Also, internally there are some rare example of non-existent styles (
styles.unknown
) being used which can cause the Babel plugin to throw an error.Added a check to bail out instead of throwing an error for such cases and added a couple of test cases to verify that the fix works for
stylex()
,stylex.props()
andstylex.attrs()
.