Files
test-repo/changelog_unreleased/javascript/pr-8097.md
T
Abdullah AttaandGeorgii Dolzhykov 8acc9e2a48 fix inconsistent parsing of injected expressions in styled-components' css (#8097)
* fix inconsistent parsing of styled-components' css

* fix for multiple placeholders in one line

* add test for multiple placeholders in one line

* add changelog for the pr

* fix multi part placeholders

* make placeholderMatch regex stricter

* add tests for all fixed cases

* update changelog

* fix changelog link

* do not edit the original doc.parts

* fix changelog output

* simplify logic

* remove unnecessary `tokens` array

* simplify logic even more

* changes according to review

* finalize

* update snapshots after merge

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-05-07 16:06:13 +03:00

898 B

Fix inconsistent parsing of injected expressions in styled-components template literals (#8097 by @thecodrr)

// Input
const SingleConcat = styled.div`
  ${something()}
  & > ${Child}:not(:first-child) {
margin-left:5px;
}
`

const MultiConcats = styled.div`
  ${something()}
  & > ${Child}${Child2}:not(:first-child) {
margin-left:5px;
}
`

const SeparatedConcats = styled.div`
font-family: "${a}", "${b}";
`

// Prettier stable -- same as input

// Prettier master
const SingleConcat = styled.div`
  ${something()}
  & > ${Child}:not(:first-child) {
    margin-left: 5px;
  }
`;

const MultiConcats = styled.div`
  ${something()}
  & > ${Child}${Child2}:not(:first-child) {
    margin-left: 5px;
  }
`;

const SeparatedConcats = styled.div`
  font-family: "${a}", "${b}";
`;