feat(css): lowercase wide keywords

master
evilebottnawi 2018-01-23 18:10:39 +03:00
parent 3bc3e801c8
commit 591ee5a425
5 changed files with 38 additions and 2 deletions

View File

@ -22,7 +22,11 @@ function clean(ast, newObj) {
}
if (
(ast.type === "value-word" && ast.isColor && ast.isHex) ||
(ast.type === "value-word" &&
((ast.isColor && ast.isHex) ||
["initial", "inherit", "unset", "revert"].indexOf(
newObj.value.replace().toLowerCase()
) !== -1)) ||
ast.type === "media-feature" ||
ast.type === "selector-root-invalid" ||
ast.type === "selector-pseudo"

View File

@ -421,7 +421,7 @@ function genericPrint(path, options, print) {
return n.value;
}
case "value-word": {
if (n.isColor && n.isHex) {
if ((n.isColor && n.isHex) || isWideKeywords(n.value)) {
return n.value.toLowerCase();
}
return n.value;
@ -551,6 +551,14 @@ function maybeToLowerCase(value) {
: value.toLowerCase();
}
function isWideKeywords(value) {
return (
["initial", "inherit", "unset", "revert"].indexOf(
value.replace().toLowerCase()
) !== -1
);
}
module.exports = {
options: printerOptions,
print: genericPrint,

View File

@ -21,6 +21,10 @@ svg[viewBox] linearGradient,
background: Var(--Keep-custom-Prop);
animation-name: KeepAnimationName;
important: something !IMPORTANT;
font-family: INITIAL;
padding: UNSET;
border: INHERIT;
all: REVERT;
}
@keyframes KeepAnimationName {
@ -109,6 +113,10 @@ svg[viewBox] linearGradient,
background: Var(--Keep-custom-Prop);
animation-name: KeepAnimationName;
important: something !IMPORTANT;
font-family: initial;
padding: unset;
border: inherit;
all: revert;
}
@keyframes KeepAnimationName {
@ -207,6 +215,10 @@ svg[viewBox] linearGradient,
background: Var(--Keep-custom-Prop);
animation-name: KeepAnimationName;
important: something !IMPORTANT;
font-family: INITIAL;
padding: UNSET;
border: INHERIT;
all: REVERT;
}
@keyframes KeepAnimationName {
@ -297,6 +309,10 @@ svg[viewBox] linearGradient,
background: Var(--Keep-custom-Prop);
animation-name: KeepAnimationName;
important: something !important;
font-family: initial;
padding: unset;
border: inherit;
all: revert;
}
@keyframes KeepAnimationName {

View File

@ -18,6 +18,10 @@ svg[viewBox] linearGradient,
background: Var(--Keep-custom-Prop);
animation-name: KeepAnimationName;
important: something !IMPORTANT;
font-family: INITIAL;
padding: UNSET;
border: INHERIT;
all: REVERT;
}
@keyframes KeepAnimationName {

View File

@ -17,6 +17,10 @@ svg[viewBox] linearGradient,
background: Var(--Keep-custom-Prop);
animation-name: KeepAnimationName;
important: something !IMPORTANT;
font-family: INITIAL;
padding: UNSET;
border: INHERIT;
all: REVERT;
}
@keyframes KeepAnimationName {