Skip to content

Commit abf45d3

Browse files
committed
add comment support
1 parent a1f0b0d commit abf45d3

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,22 @@ Compiler.prototype.compile = function(node){
3636
*/
3737

3838
Compiler.prototype.visit = function(node){
39+
if (node.comment) return this.comment(node);
3940
if (node.charset) return this.charset(node);
4041
if (node.keyframes) return this.keyframes(node);
4142
if (node.media) return this.media(node);
4243
if (node.import) return this.import(node);
4344
return this.rule(node);
4445
};
4546

47+
/**
48+
* Visit comment node.
49+
*/
50+
51+
Compiler.prototype.comment = function(node){
52+
return '/*' + node.comment + '*/';
53+
};
54+
4655
/**
4756
* Visit import node.
4857
*/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"devDependencies": {
88
"mocha": "*",
99
"should": "*",
10-
"css-parse": "1.0.3"
10+
"css-parse": "1.1.0"
1111
},
1212
"main": "index"
1313
}

test/cases/comments.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* comment */
2+
3+
body {
4+
color: #eee
5+
}

test/css-stringify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('stringify(obj)', function(){
1818
var css = read(path.join('test', 'cases', file + '.css'), 'utf8');
1919
if (compress) file = file.replace('.compress', '');
2020
var ret = stringify(parse(css), { compress: compress });
21-
ret.should.equal(css);
21+
ret.trim().should.equal(css.trim());
2222
});
2323
});
24-
});
24+
});

0 commit comments

Comments
 (0)