Strip leading space for first combinators (#1807)
parent
27df0f81f5
commit
f34492d7e5
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -8,3 +8,24 @@ exports[`combinator.css 1`] = `
|
|||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`leading.css 1`] = `
|
||||
a {
|
||||
> * {
|
||||
}
|
||||
&, > * {
|
||||
}
|
||||
+ * {
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
a {
|
||||
> * {
|
||||
}
|
||||
&, > * {
|
||||
}
|
||||
+ * {
|
||||
}
|
||||
}
|
||||
|
||||
`;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
a {
|
||||
> * {
|
||||
}
|
||||
&, > * {
|
||||
}
|
||||
+ * {
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue