File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ module.exports = function parse(html, options) {
2222 inComponent = false ;
2323 }
2424 }
25+ // check if this is a comment tag. if so, just return.
26+ if ( tag . indexOf ( '<!--' ) === 0 ) {
27+ return ;
28+ }
2529 var isOpen = tag . charAt ( 1 ) !== '/' ;
2630 var start = index + tag . length ;
2731 var nextChar = html . charAt ( start ) ;
Original file line number Diff line number Diff line change @@ -366,6 +366,18 @@ test('parse', function (t) {
366366 { type : 'text' , content : 'There' }
367367 ]
368368 } ] , 'should remove text nodes that are nothing but whitespace' ) ;
369+
370+ html = '<!--\n\t<style type="text/css">\n\t\t.header {\n\t\t\tfont-size: 14px;\n\t\t}\n\t</style>\n\n-->\n<div>Hi</div>' ;
371+ parsed = HTML . parse ( html ) ;
372+ t . deepEqual ( parsed , [ {
373+ type : 'tag' ,
374+ name : 'div' ,
375+ attrs : { } ,
376+ voidElement : false ,
377+ children : [
378+ { type : 'text' , content : 'Hi' }
379+ ]
380+ } ] , 'should ignore HTML comments' ) ;
369381 t . end ( ) ;
370382} ) ;
371383
You can’t perform that action at this time.
0 commit comments