-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Labels
area:multiparserIssues with printing one language inside another, like CSS-in-JSIssues with printing one language inside another, like CSS-in-JSlang:css/scss/lessIssues affecting CSS, Less or SCSSIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Prettier 1.16.4
Playground link
--parser babylonWhen using JS template literals inside the multiparser, line breaks before long template expressions can add invalid spaces/newlines to CSS.
Prettier sometimes adds a line break before the opening ${, which can change e.g. flex-direction: row-reverse; to something like flex-direction: row -reverse.
This breaks the syntax of the rendered CSS.
Input:
const long_cond = true;
<style jsx>{`
.class{
flex-direction: column${long_cond && long_cond && long_cond ? "-reverse" : ""};
}
`}</style>Output:
const long_cond = true;
<style jsx>{`
.class {
flex-direction: column
${long_cond && long_cond && long_cond ? "-reverse" : ""};
}
`}</style>;With the template substitution, this eventually gets inserted into the DOM as the following css:
.class {
flex-direction: column -reverse
}Note the space between column and -reverse.
Expected behavior:
const long_cond = true;
<style jsx>{`
.class {
flex-direction: column${
long_cond && long_cond && long_cond
? "-reverse"
: ""};
}
`}</style>;...which should produce the following css:
.class {
flex-direction: column-reverse
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:multiparserIssues with printing one language inside another, like CSS-in-JSIssues with printing one language inside another, like CSS-in-JSlang:css/scss/lessIssues affecting CSS, Less or SCSSIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.