Skip to content

Commit

Permalink
Join multiple word tokens together. Fixes #4.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-eb committed May 29, 2015
1 parent 842e4e6 commit aded33a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/__tests__/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ test('qualified class', 'button.btn-primary', (t, tree) => {
t.equal(tree.selectors[0].rules[0].type, 'tag');
t.equal(tree.selectors[0].rules[1].type, 'class');
});

test('escaped numbers in class name', '.\\31\\ 0', (t, tree, d) => {
t.plan(2);
t.equal(tree.selectors[0].rules[0].type, 'class');
t.equal(tree.selectors[0].rules[0].value, '\\31\\ 0');
});
12 changes: 12 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ export default class Parser {
return this.namespace();
}
let word = this.tokens[this.position][1];
while (this.tokens[this.position + 1] && this.tokens[this.position + 1][0] === 'word') {
this.position ++;
let current = this.tokens[this.position][1];
word += current;
if (current.lastIndexOf('\\') === current.length - 1) {
let next = this.tokens[this.position + 1];
if (next[0] === 'space') {
word += next[1];
this.position ++;
}
}
}
let hasClass = indexesOf(word, '.');
let hasId = indexesOf(word, '#');
if (hasId.length > 1) {
Expand Down

0 comments on commit aded33a

Please sign in to comment.