Skip to content
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 broken css prop ternaries when referencing cssMap objects. #1767

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

kylorhall-atlassian
Copy link
Collaborator

What is this change?

We extract nested member expressions inside of conditional expressions.

Why are we making this change?

Fixes #1750

How are we making this change?

We simply copy the direct buildCss > MemberExpression > … extraction into a new path through buildCss > ConditionalExpression > extractConditionalExpression(…) > MemberExpression > ….

…I believe this is safe and well protected, given the underlying extractMemberExpression code already existed!


PR checklist

I have...

  • Updated or added applicable tests
  • Updated the documentation in website/ n/a
  • Added a changeset (if making any changes that affect Compiled's behaviour)

…tional expressions.

Fixes #1750

We simply copy the direct `buildCss > MemberExpression > …` extraction into a new path through `buildCss > ConditionalExpression > extractConditionalExpression(…) > MemberExpression > …`.
Copy link

changeset-bot bot commented Dec 17, 2024

🦋 Changeset detected

Latest commit: 5bcb62a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@compiled/babel-plugin Minor
@compiled/parcel-transformer Patch
@compiled/webpack-loader Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Dec 17, 2024

Deploy Preview for compiled-css-in-js canceled.

Name Link
🔨 Latest commit 5bcb62a
🔍 Latest deploy log https://app.netlify.com/sites/compiled-css-in-js/deploys/67628b80a6c6e40008e21a01

};
}

if (fallbackToEvaluate) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel a bit annoyed by adding this false here, but I get into this endless loop with non-cssMap objects, eg. loading ? colors.N20 : colors.N40 where it blew up in a test.

This keeps it 1:1 with the current state by default and lets this if (bindingIdentifier && meta.state.cssMap[bindingIdentifier.name]) { flow be reused in extractConditionalExpression, so it feels sane to me.

dddlr
dddlr previously approved these changes Dec 18, 2024
@kylorhall-atlassian kylorhall-atlassian merged commit 0ebbfc1 into master Dec 18, 2024
13 checks passed
@kylorhall-atlassian kylorhall-atlassian deleted the kylorhall/fix-css-map-ternaries branch December 18, 2024 22:26
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.

Ternaries within css do not get extracted with cssMap
2 participants