Skip to content

Commit 6b499c6

Browse files
committed
fix parse for top level text nodes
1 parent aeb413e commit 6b499c6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/parse.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ module.exports = function parse(html, options) {
1515
var byTag = {};
1616
var inComponent = false;
1717

18+
if (!new RegExp(tagRE).test(html)) {
19+
result.push({
20+
type: 'text',
21+
content: html
22+
});
23+
}
24+
1825
html.replace(tagRE, function (tag, index) {
1926
if (inComponent) {
2027
if (tag !== ('</' + current.name + '>')) {

test/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ test('parse', function (t) {
382382
var name = splitted[0];
383383
}
384384
}();
385-
</script>`
385+
</script>`;
386386
parsed = HTML.parse(html);
387387
t.deepEqual(parsed, [{
388388
type: 'tag',

0 commit comments

Comments
 (0)