Skip to content

Commit

Permalink
Fixes a crash when a backslash is the last character.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-eb committed Jun 23, 2015
1 parent 341b79a commit 01a6b34
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.1.1

* Fixes a crash when a backslash ended a selector string.

# 1.1.0

* Adds support for replacing multiple nodes at once with `replaceWith`
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ test('tag with trailing comma', 'h1,', (t, tree) => {
t.plan(1);
t.equal(tree.trailingComma, true);
});

test('tag with trailing slash', 'h1\\', (t, tree) => {
t.plan(1);
t.equal(tree.nodes[0].nodes[0].value, 'h1\\');
});
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default class Parser {
word += current;
if (current.lastIndexOf('\\') === current.length - 1) {
let next = this.nextToken;
if (next[0] === 'space') {
if (next && next[0] === 'space') {
word += next[1];
this.position ++;
}
Expand Down

0 comments on commit 01a6b34

Please sign in to comment.