Skip to content

Don't lowercase element names and attribute names in selectors - #3317

Merged
lydell merged 2 commits into
prettier:masterfrom
lydell:css-case-fix
Nov 27, 2017
Merged

lydell merged 2 commits into
prettier:masterfrom
lydell:css-case-fix

Conversation

@lydell

@lydell lydell commented Nov 25, 2017

Copy link
Copy Markdown
Member

https://www.w3.org/TR/css3-selectors/#casesens

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.

Fixes #3304.

Comment thread tests/css_case/case.less
.Keep (@Keep) WHEN (lightness(@Keep) >= Keep12PX) AND (@Keep > @Keep12E5) {}
.Keep (@Keep) when (lightness(@Keep) >= 12PX) and (@Keep > 0) {}
.Keep (@Keep) when (lightness(@Keep) != '12PX') and (@Keep != "12PX") {}
.Keep (@Keep) when (lightness(@Keep) >= Keep12PX) and (@Keep > @Keep12E5) {}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, Less only accepts when and and lowercase.

@keyframes KeepAnimationName {
from {
FROM {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from and to could technically be lowercased in @keyframes, but I don’t think it is worth the trouble.

// - The case should always be preserved for element names and attribute names
// in selectors, as well as function names and property keywords.
// - Other things should mostly be lowercase.
// - The \`/*:*/\` comments are just to bust the \`isLikelySCSS\` check.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but can we use parser: "less" instead of the comments now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t know.

https://www.w3.org/TR/css3-selectors/#casesens

> 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.

Fixes prettier#3304.
#{$KeepInterpolationVar},
#{$Keep + 15px},
#{$Keep + 15PX},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I didn't see this one when looking through the diff before. Need to lowercase that "PX".

@azz

azz commented Nov 27, 2017

Copy link
Copy Markdown
Member

Good to merge?

@lydell
lydell merged commit 56951a7 into prettier:master Nov 27, 2017
@lydell
lydell deleted the css-case-fix branch November 27, 2017 12:28
@suchipi suchipi added this to the 1.9 milestone Nov 28, 2017
@lock lock Bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 19, 2019
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants