Skip to content

Commit

Permalink
Allow escaped dot within class name
Browse files Browse the repository at this point in the history
  • Loading branch information
plesiecki authored and jonathantneal committed Dec 22, 2018
1 parent c6e79b4 commit 5ad61d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/__tests__/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ test('ClassName#set value', ".fo\\o", (t, selectors) => {
className.value = "bar";
t.deepEqual(className.raws, {});
});

test('escaped dot in class name', '.foo\\.bar', (t, tree) => {
t.deepEqual(tree.nodes[0].nodes[0].type, 'class');
t.deepEqual(tree.nodes[0].nodes[0].value, 'foo.bar');
t.deepEqual(tree.nodes[0].nodes[0].raws.value, 'foo\\.bar');
});
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ export default class Parser {
}
nextToken = this.nextToken;
}
const hasClass = indexesOf(word, '.');
const hasClass = indexesOf(word, '.').filter(i => word[i - 1] !== '\\');
let hasId = indexesOf(word, '#');
// Eliminate Sass interpolations from the list of id indexes
const interpolations = indexesOf(word, '#{');
Expand Down

0 comments on commit 5ad61d6

Please sign in to comment.