diff --git a/CHANGELOG.md b/CHANGELOG.md index caad483..2d4f264 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/src/__tests__/tags.js b/src/__tests__/tags.js index cc8fd23..efd76ca 100644 --- a/src/__tests__/tags.js +++ b/src/__tests__/tags.js @@ -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\\'); +}); diff --git a/src/parser.js b/src/parser.js index 7ffae38..ce48a1e 100644 --- a/src/parser.js +++ b/src/parser.js @@ -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 ++; }