Skip to content

Commit b4e9836

Browse files
committed
Fix comment tag parsing that dont have whitespace after comment start token
1 parent e71407b commit b4e9836

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/parse-tag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = function (tag) {
3838
res.voidElement = true;
3939
}
4040

41-
if (res.name === '!--') { // comment tag
41+
if (res.name.startsWith('!--')) { // comment tag
4242
res = {
4343
type: 'comment',
4444
};

test/parse.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ test('parse', function (t) {
8484
}]);
8585
t.equal(html, HTML.stringify(parsed));
8686

87+
html = '<!---->'
88+
parsed = HTML.parse(html);
89+
t.deepEqual(parsed, [{
90+
type: 'comment',
91+
comment: ''
92+
}]);
93+
t.equal(html, HTML.stringify(parsed));
94+
95+
html = '<!---this comment starts with a hyphen b/c web developers love curveballs -->'
96+
parsed = HTML.parse(html);
97+
t.deepEqual(parsed, [{
98+
type: 'comment',
99+
comment: '-this comment starts with a hyphen b/c web developers love curveballs '
100+
}]);
101+
t.equal(html, HTML.stringify(parsed));
87102

88103
html = '<div>oh <strong>hello</strong> there! How are <span>you</span>?</div>';
89104
parsed = HTML.parse(html);

0 commit comments

Comments
 (0)