Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Nov 27, 2017

Conversation

lydell
Copy link
Member

@lydell lydell commented Nov 25, 2017

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.

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

@@ -292,17 +300,17 @@ a[href="KeepAttrValue"]:hover::first-letter,
}

@keyframes KeepAnimationName {
from {
FROM {
Copy link
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.

@@ -89,15 +91,17 @@ $KeepScssVar: val;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Convention in this test file:
// - The case should be preserved for things prefixed with "Keep".
// - The case should always be preserved for function names and property keywords.
// - 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
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
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.
prop: val;
}

#{$KeepInterpolationVar},
#{$Keep + 15px},
#{$Keep + 15PX},
Copy link
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
Copy link
Member

azz commented Nov 27, 2017

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.

None yet

3 participants