Skip to content

Commit d13136c

Browse files
committed
Make sure we calculate the correct end of the text node when it's the last node in the html string.
1 parent 77186c2 commit d13136c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/parse.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ module.exports = function parse(html, options) {
6666
// if we're at the root, push a base text node. otherwise add as
6767
// a child to the current node.
6868
parent = level === -1 ? result : arr[level].children;
69+
70+
// calculate correct end of the content slice in case there's
71+
// no tag after the text node.
72+
var end = html.indexOf('<', start);
73+
end = end === -1 ? undefined : end;
6974
parent.push({
7075
type: 'text',
71-
content: html.slice(start, html.indexOf('<', start))
76+
content: html.slice(start, end)
7277
});
7378
}
7479
}

0 commit comments

Comments
 (0)