CSS: lowercase hex colors, closes #2139 (#2203)

master
Lucas Azzola 2017-06-20 23:07:31 +10:00 committed by GitHub
parent 16db5971f0
commit 43521565e7
6 changed files with 36 additions and 1 deletions

View File

@ -74,6 +74,10 @@ function massageAST(ast) {
newObj.value = newObj.value.replace(/ /g, "");
}
if (ast.type === "value-word" && ast.isColor && ast.isHex) {
newObj.value = newObj.value.toLowerCase();
}
// (TypeScript) Ignore `static` in `constructor(static p) {}`
// and `export` in `constructor(export p) {}`
if (

View File

@ -317,6 +317,9 @@ function genericPrint(path, options, print) {
return n.value;
}
case "value-word": {
if (n.isColor && n.isHex) {
return n.value.toLowerCase();
}
return n.value;
}
case "value-colon": {

View File

@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`hexcolor.css 1`] = `
.foo {
color: #AAA;
-o-color: #fabcd3;
-webkit-color: #873;
-moz-color: #6bcdef;
-ms-color: #AAbbCC;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.foo {
color: #aaa;
-o-color: #fabcd3;
-webkit-color: #873;
-moz-color: #6bcdef;
-ms-color: #aabbcc;
}
`;

View File

@ -0,0 +1,7 @@
.foo {
color: #AAA;
-o-color: #fabcd3;
-webkit-color: #873;
-moz-color: #6bcdef;
-ms-color: #AAbbCC;
}

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "postcss" });

View File

@ -4,7 +4,7 @@ exports[`color-hex-lowercase.css 1`] = `
.foo{color:#ABCDEF}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.foo {
color: #ABCDEF;
color: #abcdef;
}
`;