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(styled-components): fix displayName and ssr feature not working in some cases #240

Merged
merged 26 commits into from
Nov 28, 2023

Conversation

ciffelia
Copy link
Contributor

@ciffelia ciffelia commented Nov 27, 2023

This fixes display_name_and_id is not working as expected when styled components are created using function call (not tagged template) with attrs or withConfig. Some conditions were slightly different from original: https://github.com/styled-components/babel-plugin-styled-components/blob/4e2eb388d9c90f2921c306c760657d059d01a518/src/visitors/displayNameAndId.js#L205-L227

const WrappedComponent4 = styled(Inner).attrs(() => ({ something: 'else' }))(/* ...  */)
const WrappedComponent5 = styled.div.attrs(() => ({ something: 'else' }))(/* ...  */)
const WrappedComponent8 = styled.div
  .withConfig({
    shouldForwardProp: () => {},
  })
  .attrs(() => ({ something: 'else' }))(/* ...  */)

Also, this PR adds some tests; please see individual commits for details.

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Thank you!

@kdy1 kdy1 enabled auto-merge (squash) November 28, 2023 10:48
@kdy1 kdy1 merged commit 6dca40d into swc-project:main Nov 28, 2023
6 checks passed
@ciffelia ciffelia deleted the test-styled-components-fix-tests branch November 28, 2023 11:45
@kdy1 kdy1 self-assigned this Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants