Skip to content

Commit 18ecae9

Browse files
committed
Make sure there's a token after the combinator.
1 parent 51879ab commit 18ecae9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/__tests__/combinators.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ test('trailing combinator & spaces', 'p + ', (t, tree) => {
124124
t.deepEqual(tree.nodes[0].nodes[0].value, 'p', 'should be a paragraph');
125125
t.deepEqual(tree.nodes[0].nodes[1].value, '+', 'should have a combinator');
126126
});
127+
128+
test('trailing sibling combinator', 'p ~', (t, tree) => {
129+
t.deepEqual(tree.nodes[0].nodes[0].value, 'p', 'should be a paragraph');
130+
t.deepEqual(tree.nodes[0].nodes[1].value, '~', 'should have a combinator');
131+
});
132+
127133
test('ending in comment has no trailing combinator', ".bar /* comment 3 */", (t, tree) => {
128134
let nodeTypes = tree.nodes[0].map(n => n.type);
129135
t.deepEqual(nodeTypes, ["class"]);

src/parser.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export default class Parser {
121121
this.root.append(selector);
122122
this.current = selector;
123123

124-
125124
this.loop();
126125
}
127126

@@ -578,7 +577,7 @@ export default class Parser {
578577
});
579578
}
580579

581-
if (this.currToken[TOKEN.TYPE] === tokens.space) {
580+
if (this.currToken && this.currToken[TOKEN.TYPE] === tokens.space) {
582581
node.spaces.after = this.optionalSpace(this.content());
583582
this.position++;
584583
}

0 commit comments

Comments
 (0)