You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Styled-components integration lowercases SVG tag names in selectors #3304
lang:css/scss/lessIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!
changed the title [-]Styled-components integration breaks selectors[/-][+]Styled-components integration lowercases SVG tag names in selectors[/+]on Nov 21, 2017
Not a great workaround, but it'll work until this gets fixed.
Very much a rare occurrence, as not many people would ever be targeting a <linearGradient> node in a styled-component selector. We've got some SVG icons that use gradients, which is why we ran into this.
I was very surprised to find that prettier was reformatting content within a string though. Expressions I can see, but string content?
We format the contents of the styled components as CSS. And one the formatting we do is normalization: lowercase tags, properties and values; numbers; quotes; etc.
All Selectors syntax is case-insensitive within the ASCII range (i.e. [a-z] and [A-Z] are equivalent), except for parts that are not under the control of Selectors. The case sensitivity of document language element names, attribute names, and attribute values in selectors depends on the document language. For example, in HTML, element names are case-insensitive, but in XML, they are case-sensitive.
SVG is XML, not HTML, so that explains why it's case sensitive.
We have to remove all lowercasing of element names and attribute names, because we cannot know if a piece of CSS is styling HTML or XML.
SVG CSS case sensitivity test case
If things were case insensitive, you'd see green stuff in this test case. But in the real, case sensitive, world, things are red.
I was going to recommend keeping a whitelist of HTML tag names to lowercase and keeping the case of everything else, but unfortunately, you could create an XML document that uses the same tag names as HTML does...
lang:css/scss/lessIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!
Activity
[-]Styled-components integration breaks selectors[/-][+]Styled-components integration lowercases SVG tag names in selectors[/+]suchipi commentedon Nov 21, 2017
Priority high since the selector doesn't target the correct element anymore once it's been lowercased (note that SVG elements are case-sensitive).
seancurtis commentedon Nov 22, 2017
We can get around this temporarily by either adding these files to our
.prettierignorefile, or by doing:Not a great workaround, but it'll work until this gets fixed.
Very much a rare occurrence, as not many people would ever be targeting a
<linearGradient>node in a styled-component selector. We've got some SVG icons that use gradients, which is why we ran into this.I was very surprised to find that prettier was reformatting content within a string though. Expressions I can see, but string content?
duailibe commentedon Nov 22, 2017
We format the contents of the styled components as CSS. And one the formatting we do is normalization: lowercase tags, properties and values; numbers; quotes; etc.
We didn't take into account case sensitive tags..
lydell commentedon Nov 22, 2017
Sorry, I didn't read the CSS specification carefully enough when I implemented the lowercasing stuff :(
https://www.w3.org/TR/css3-selectors/#casesens
SVG is XML, not HTML, so that explains why it's case sensitive.
We have to remove all lowercasing of element names and attribute names, because we cannot know if a piece of CSS is styling HTML or XML.
SVG CSS case sensitivity test case
If things were case insensitive, you'd see green stuff in this test case. But in the real, case sensitive, world, things are red.
suchipi commentedon Nov 24, 2017
I was going to recommend keeping a whitelist of HTML tag names to lowercase and keeping the case of everything else, but unfortunately, you could create an XML document that uses the same tag names as HTML does...
Don't lowercase element names and attribute names in selectors
Don't lowercase element names and attribute names in selectors
Don't lowercase element names and attribute names in selectors
Don't lowercase element names and attribute names in selectors
Don't lowercase element names and attribute names in selectors (#3317)