Strip leading space for first combinators (#1807)

master
Christopher Chedeau 2017-05-29 12:49:25 -07:00 committed by GitHub
parent 27df0f81f5
commit f34492d7e5
5 changed files with 37 additions and 6 deletions

View File

@ -2690,7 +2690,9 @@ function genericPrintNoParens(path, options, print, args) {
}
case "selector-combinator": {
if (n.value === "+" || n.value === ">" || n.value === "~") {
return concat([" ", n.value, " "]);
const parent = path.getParentNode();
const leading = parent.type === "selector-selector" && parent.nodes[0] === n ? "" : " ";
return concat([leading, n.value, " "]);
}
return n.value;
}

View File

@ -8,3 +8,24 @@ exports[`combinator.css 1`] = `
}
`;
exports[`leading.css 1`] = `
a {
> * {
}
&, > * {
}
+ * {
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a {
> * {
}
&, > * {
}
+ * {
}
}
`;

View File

@ -0,0 +1,8 @@
a {
> * {
}
&, > * {
}
+ * {
}
}

View File

@ -29,13 +29,13 @@ color:blue;} &:nth-child(5n+1) {
&:nth-child(-n + 3) {
color: green;
}
> li > a {
> li > a {
color: red;
}
> li > li {
> li > li {
color: blue;
}
> p + p {
> p + p {
color: green;
}
}

View File

@ -20,12 +20,12 @@ padding: 10px; .nested-2-1{
.foo {
font-size: 12px;
> .nested-1 {
> .nested-1 {
padding: 10px;
.nested-2-1 {
color: red;
}
+ .nested-2-2 {
+ .nested-2-2 {
color: blue;
}
}