Skip to content

Commit aded33a

Browse files
committed
Join multiple word tokens together. Fixes #4.
1 parent 842e4e6 commit aded33a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/__tests__/classes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ test('qualified class', 'button.btn-primary', (t, tree) => {
2020
t.equal(tree.selectors[0].rules[0].type, 'tag');
2121
t.equal(tree.selectors[0].rules[1].type, 'class');
2222
});
23+
24+
test('escaped numbers in class name', '.\\31\\ 0', (t, tree, d) => {
25+
t.plan(2);
26+
t.equal(tree.selectors[0].rules[0].type, 'class');
27+
t.equal(tree.selectors[0].rules[0].value, '\\31\\ 0');
28+
});

src/parser.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,18 @@ export default class Parser {
234234
return this.namespace();
235235
}
236236
let word = this.tokens[this.position][1];
237+
while (this.tokens[this.position + 1] && this.tokens[this.position + 1][0] === 'word') {
238+
this.position ++;
239+
let current = this.tokens[this.position][1];
240+
word += current;
241+
if (current.lastIndexOf('\\') === current.length - 1) {
242+
let next = this.tokens[this.position + 1];
243+
if (next[0] === 'space') {
244+
word += next[1];
245+
this.position ++;
246+
}
247+
}
248+
}
237249
let hasClass = indexesOf(word, '.');
238250
let hasId = indexesOf(word, '#');
239251
if (hasId.length > 1) {

0 commit comments

Comments
 (0)