File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ function htmlToAST(HTMLDoc) {
3232 * @returns {AST }
3333 */
3434function modifyASTTree ( tree , options ) {
35+ var delComments = [ ] ;
36+
3537 _ . forEach ( tree , function ( node ) {
3638 if ( options . ignoreWhitespace && node . type === 'text' ) {
3739
@@ -43,6 +45,12 @@ function modifyASTTree(tree, options) {
4345 return ;
4446 }
4547
48+ if ( options . ignoreHtmlComments && node . type === 'comment' ) {
49+ delComments . push ( tree . indexOf ( node ) ) ;
50+
51+ return ;
52+ }
53+
4654 if ( node . hasOwnProperty ( 'attribs' ) ) {
4755 var attrs = utils . sortObj ( node [ 'attribs' ] ) ;
4856
@@ -76,6 +84,10 @@ function modifyASTTree(tree, options) {
7684 }
7785 } ) ;
7886
87+ for ( var i = 0 ; i < delComments . length ; i ++ ) {
88+ tree . splice ( delComments [ i ] - i , 1 ) ;
89+ }
90+
7991 return tree ;
8092}
8193
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ exports.defaults = function(options) {
5959 compareHtmlAttrsAsJSON : [ ] ,
6060
6161 ignoreWhitespace : true ,
62+ ignoreHtmlComments : true ,
6263
6364 bem : false
6465 } ) ;
You can’t perform that action at this time.
0 commit comments