Open gerriet-hinrichs opened 4 years ago
This issue is hard to fix:
A workaround would be to simply use the more specific attributes like so:
const borderStyle = 'solid';
const styles = css`
div {
border: 1px none black;
border-style: ${borderStyle};
}
`;
I've written a quick test for this issue that you can add to your tests:
// test for github issue #19
const CSS_SHORTHAND_SOURCE = `
const borderStyle = 'solid';
const styles = css\`
div {
border: 1px \${borderStyle} #000;
}
\`;
`;
const CSS_SHORTHAND_SOURCE_MIN = `
const borderStyle = 'solid';
const styles = css\`div{border:1px \${borderStyle} #000}\`;
`;
it('should handle templates in shorthand attributes correctly', () => {
const result = minifyHTMLLiterals(CSS_SHORTHAND_SOURCE, {
fileName: 'test.js'
});
expect(result).to.be.an('object');
expect(result!.code).to.equal(CSS_SHORTHAND_SOURCE_MIN);
});
Having a placeholder with a semicolon breaks the css if added to shorthand attribute values like
border
.Code to reproduce: