Skip to content

Commit 77186c2

Browse files
committed
When there are top-level text nodes, add them to the results array instead of one level up when at level 0.
1 parent 161557d commit 77186c2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/parse.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ module.exports = function parse(html, options) {
6363
level--;
6464
if (!inComponent && nextChar !== '<' && nextChar) {
6565
// trailing text node
66-
arr[level].children.push({
66+
// if we're at the root, push a base text node. otherwise add as
67+
// a child to the current node.
68+
parent = level === -1 ? result : arr[level].children;
69+
parent.push({
6770
type: 'text',
6871
content: html.slice(start, html.indexOf('<', start))
6972
});

0 commit comments

Comments
 (0)