Skip to content

Commit adcfc01

Browse files
mariovalneytonyganch
authored andcommitted
Ignore leading combinators
Issue 551
1 parent 269e854 commit adcfc01

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

src/options/space-before-combinator.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ module.exports = {
2424

2525
ast.traverseByType('combinator', function(combinator, i, parent) {
2626
var previousNode = parent.get(i - 1);
27-
if (previousNode && previousNode.is('space')) {
27+
28+
if (!previousNode) return;
29+
30+
if (previousNode.is('space')) {
2831
previousNode.content = value;
2932
} else {
3033
var space = gonzales.createNode({
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
a >b {
2+
color: red;
3+
4+
& >c {
5+
color: red;
6+
}
7+
}
8+
9+
a {
10+
color: red;
11+
12+
>c {
13+
color: red;
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
a>b {
2+
color: red;
3+
4+
&>c {
5+
color: red;
6+
}
7+
}
8+
9+
a {
10+
color: red;
11+
12+
>c {
13+
color: red;
14+
}
15+
}

test/options/space-before-combinator/process/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,11 @@ describe('Option `space-before-combinator`, process', function() {
3232
return test.shouldBeEqual('test.css', 'test-3.expected.css');
3333
});
3434
});
35+
36+
describe('scss', function() {
37+
it('Should not touch leading combinators', function() {
38+
let test = new Test(this, {'space-before-combinator': ' '});
39+
return test.shouldBeEqual('test.scss', 'test.expected.scss');
40+
});
41+
});
3542
});

0 commit comments

Comments
 (0)