Skip to content

Commit

Permalink
Ignore leading combinators
Browse files Browse the repository at this point in the history
Issue 551
  • Loading branch information
mariovalney authored and tonyganch committed Mar 22, 2019
1 parent 269e854 commit adcfc01
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/options/space-before-combinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ module.exports = {

ast.traverseByType('combinator', function(combinator, i, parent) {
var previousNode = parent.get(i - 1);
if (previousNode && previousNode.is('space')) {

if (!previousNode) return;

if (previousNode.is('space')) {
previousNode.content = value;
} else {
var space = gonzales.createNode({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
a >b {
color: red;

& >c {
color: red;
}
}

a {
color: red;

>c {
color: red;
}
}
15 changes: 15 additions & 0 deletions test/options/space-before-combinator/process/scss/test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
a>b {
color: red;

&>c {
color: red;
}
}

a {
color: red;

>c {
color: red;
}
}
7 changes: 7 additions & 0 deletions test/options/space-before-combinator/process/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ describe('Option `space-before-combinator`, process', function() {
return test.shouldBeEqual('test.css', 'test-3.expected.css');
});
});

describe('scss', function() {
it('Should not touch leading combinators', function() {
let test = new Test(this, {'space-before-combinator': ' '});
return test.shouldBeEqual('test.scss', 'test.expected.scss');
});
});
});

0 comments on commit adcfc01

Please sign in to comment.