From 01a6b346e3612ce1ab20219acc26abdc259ccefb Mon Sep 17 00:00:00 2001 From: Ben Briggs Date: Tue, 23 Jun 2015 23:58:25 +0100 Subject: [PATCH] Fixes a crash when a backslash is the last character. --- CHANGELOG.md | 4 ++++ src/__tests__/tags.js | 5 +++++ src/parser.js | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) 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 ++; }