File tree Expand file tree Collapse file tree 1 file changed +21
-20
lines changed Expand file tree Collapse file tree 1 file changed +21
-20
lines changed Original file line number Diff line number Diff line change 2
2
module . exports = function ( css , options ) {
3
3
options = options || { } ;
4
4
5
+ /**
6
+ * Root node.
7
+ */
8
+
9
+ var root = {
10
+ type : 'stylesheet' ,
11
+ stylesheet : { } ,
12
+ comments : [ ]
13
+ } ;
14
+
5
15
/**
6
16
* Positional.
7
17
*/
@@ -48,19 +58,6 @@ module.exports = function(css, options){
48
58
return node ;
49
59
}
50
60
51
- /**
52
- * Parse stylesheet.
53
- */
54
-
55
- function stylesheet ( ) {
56
- return {
57
- type : 'stylesheet' ,
58
- stylesheet : {
59
- rules : rules ( )
60
- }
61
- } ;
62
- }
63
-
64
61
/**
65
62
* Opening brace.
66
63
*/
@@ -118,11 +115,13 @@ module.exports = function(css, options){
118
115
* Parse comments;
119
116
*/
120
117
121
- function comments ( rules ) {
118
+ function comments ( ) {
122
119
var c ;
123
- rules = rules || [ ] ;
124
- while ( c = comment ( ) ) rules . push ( c ) ;
125
- return rules ;
120
+ while ( c = comment ( ) ) {
121
+ if ( options . comments ) {
122
+ root . comments . push ( c ) ;
123
+ }
124
+ }
126
125
}
127
126
128
127
/**
@@ -197,13 +196,13 @@ module.exports = function(css, options){
197
196
var decls = [ ] ;
198
197
199
198
if ( ! open ( ) ) return ;
200
- comments ( decls ) ;
199
+ comments ( ) ;
201
200
202
201
// declarations
203
202
var decl ;
204
203
while ( decl = declaration ( ) ) {
205
204
decls . push ( decl ) ;
206
- comments ( decls ) ;
205
+ comments ( ) ;
207
206
}
208
207
209
208
if ( ! close ( ) ) return ;
@@ -447,6 +446,8 @@ module.exports = function(css, options){
447
446
} ) ;
448
447
}
449
448
450
- return stylesheet ( ) ;
449
+ root . stylesheet . rules = rules ( ) ;
450
+
451
+ return root ;
451
452
} ;
452
453
You can’t perform that action at this time.
0 commit comments