Skip to content

Commit

Permalink
csscomb#381: Combinators can go first within selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyganch committed May 20, 2015
1 parent 6bcbfda commit 155b386
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/options/space-before-combinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ module.exports = {
var value = this.getValue('space-before-combinator');

node.forEach(function(simpleSelector) {
simpleSelector.forEach('combinator', function(combinator, i) {
var notFirst = false;

simpleSelector.forEach(function(n, i) {
if (!n.is('space') && !n.is('combinator')) notFirst = true;

// If combinator is the first thing in selector,
// do not add extra spaces:
if (!n.is('combinator') || !notFirst) return;

if (simpleSelector.get(i - 1).is('space')) {
simpleSelector.get(i - 1).content = value;
} else {
Expand Down
5 changes: 5 additions & 0 deletions test/options/space-before-combinator/issue-381.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
> .u-margins-off,
> .c-media > > *,
> .c-media-list > * > > * {
margin-top: 0;
}
5 changes: 5 additions & 0 deletions test/options/space-before-combinator/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ describe('options/space-before-combinator:', function() {
this.shouldBeEqual('test.css', 'test-3.expected.css');
});

it.only('Issue 381', function() {
this.comb.configure({ 'space-before-combinator': ' ' });
this.shouldBeEqual('issue-381.css');
});

it('Should detect no whitespaces before combinator', function() {
this.shouldDetect(
['space-before-combinator'],
Expand Down

0 comments on commit 155b386

Please sign in to comment.