Repository: postcss/postcss-selector-parser (js)

Issue:
Nested selector bug in lossy mode
#7 Introduced a bug in lossy mode.

It removes a 'space' combinator after a nested '&' token.

So '& .class' is parsed to '&.class', note the removal of the space.

I'll submit a PR.

Pull request description:
Fix lossy bug using nested selectors
fix(lossy): bug removing space combinator after nested token. Fixes #102.

Patch:
diff --git a/src/parser.js b/src/parser.js
index 3b67048..629f033 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -129,7 +129,7 @@ export default class Parser {
                 node.spaces.after = this.parseSpace(this.currToken[1]);
             } else if (this.currToken[0] === 'combinator') {
                 node.value = this.currToken[1];
-            } else if (this.currToken[0] === 'space' && !(this.lossy && this.prevToken[0] === '&')) {
+            } else if (this.currToken[0] === 'space') {
                 node.value = this.parseSpace(this.currToken[1], ' ');
             }
             this.position ++;


Test patch:
diff --git a/src/__tests__/lossy.js b/src/__tests__/lossy.js
index aa9fdc4..b05114c 100644
--- a/src/__tests__/lossy.js
+++ b/src/__tests__/lossy.js
@@ -62,7 +62,7 @@ ava('universal - qualified universal selector', testLossy, '*[href] *:not(*.gree
 
 ava('nesting - spacing before', testLossy, '  &.class', '&.class');
 ava('nesting - spacing after', testLossy, '&.class  ', '&.class');
-ava('nesting - spacing between', testLossy, '&  .class  ', '&.class');
+ava('nesting - spacing between', testLossy, '&  .class  ', '& .class');
 
 ava('pseudo (single) - spacing before', testLossy, '  :after', ':after');
 ava('pseudo (single) - spacing after', testLossy, ':after  ', ':after');