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) {
22
22
inComponent = false ;
23
23
}
24
24
}
25
+ // check if this is a comment tag. if so, just return.
26
+ if ( tag . indexOf ( '<!--' ) === 0 ) {
27
+ return ;
28
+ }
25
29
var isOpen = tag . charAt ( 1 ) !== '/' ;
26
30
var start = index + tag . length ;
27
31
var nextChar = html . charAt ( start ) ;
Original file line number Diff line number Diff line change @@ -366,6 +366,18 @@ test('parse', function (t) {
366
366
{ type : 'text' , content : 'There' }
367
367
]
368
368
} ] , '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' ) ;
369
381
t . end ( ) ;
370
382
} ) ;
371
383
You can’t perform that action at this time.
0 commit comments