Skip to content

Commit 803582f

Browse files
committed
[options] #381: Combinators can go first within selectors
1 parent 1dc47f6 commit 803582f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/options/space-before-combinator.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ module.exports = {
2323
var value = this.getValue('space-before-combinator');
2424

2525
node.forEach(function(simpleSelector) {
26-
simpleSelector.forEach('combinator', function(combinator, i) {
26+
var notFirst = false;
27+
28+
simpleSelector.forEach(function(n, i) {
29+
if (!n.is('space') && !n.is('combinator')) notFirst = true;
30+
31+
// If combinator is the first thing in selector,
32+
// do not add extra spaces:
33+
if (!n.is('combinator') || !notFirst) return;
34+
2735
if (simpleSelector.get(i - 1).is('space')) {
2836
simpleSelector.get(i - 1).content = value;
2937
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
> .u-margins-off,
2+
> .c-media > > *,
3+
> .c-media-list > * > > * {
4+
margin-top: 0;
5+
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ describe('options/space-before-combinator:', function() {
2929
this.shouldBeEqual('test.css', 'test-3.expected.css');
3030
});
3131

32+
it.only('Issue 381', function() {
33+
this.comb.configure({ 'space-before-combinator': ' ' });
34+
this.shouldBeEqual('issue-381.css');
35+
});
36+
3237
it('Should detect no whitespaces before combinator', function() {
3338
this.shouldDetect(
3439
['space-before-combinator'],

0 commit comments

Comments
 (0)