fix(css-in-js): do not remove semicolon (#5353)

master
Ika 2018-11-07 00:19:42 +08:00 committed by GitHub
parent b87fe4cf22
commit 6a54e21c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 5 deletions

View File

@ -556,7 +556,7 @@ const parser = {
if (endNode && node.source && !node.source.end) {
node = endNode;
}
if (node.source) {
if (node.source && node.source.end) {
return lineColumnToIndex(node.source.end, node.source.input.css);
}
return null;

View File

@ -185,7 +185,9 @@ function genericPrint(path, options, print) {
softline,
"}"
])
: isTemplatePropNode(node) && !parentNode.raws.semicolon
: isTemplatePropNode(node) &&
!parentNode.raws.semicolon &&
options.originalText[options.locEnd(node) - 1] !== ";"
? ""
: ";"
]);
@ -242,7 +244,9 @@ function genericPrint(path, options, print) {
softline,
"}"
])
: isTemplatePlaceholderNode(node) && !parentNode.raws.semicolon
: isTemplatePlaceholderNode(node) &&
!parentNode.raws.semicolon &&
options.originalText[options.locEnd(node) - 1] !== ";"
? ""
: ";"
]);

View File

@ -130,7 +130,17 @@ styled.span\`
styled.span\`
\${foo}:
\${bar};
\`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\`
styled.a\`
\${feedbackCountBlockCss}
text-decoration: none;
\${FeedbackCount} {
margin: 0;
}
\`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const ListItem = styled.li\`\`;
const ListItem = styled.li\`\`;
@ -263,4 +273,13 @@ styled.span\`
\${foo}: \${bar};
\`;
styled.a\`
\${feedbackCountBlockCss}
text-decoration: none;
\${FeedbackCount} {
margin: 0;
}
\`;
`;

View File

@ -127,4 +127,13 @@ ${bar}
styled.span`
${foo}:
${bar};
`
`
styled.a`
${feedbackCountBlockCss}
text-decoration: none;
${FeedbackCount} {
margin: 0;
}
`