@@ -6,7 +6,12 @@ module.exports = function(css){
66 */
77
88 function stylesheet ( ) {
9- return { stylesheet : { rules : rules ( ) } } ;
9+ return {
10+ type : 'stylesheet' ,
11+ stylesheet : {
12+ rules : rules ( )
13+ }
14+ } ;
1015 }
1116
1217 /**
@@ -86,7 +91,10 @@ module.exports = function(css){
8691 css = css . slice ( i ) ;
8792 whitespace ( ) ;
8893
89- return { comment : str } ;
94+ return {
95+ type : 'comment' ,
96+ comment : str
97+ } ;
9098 }
9199
92100 /**
@@ -120,7 +128,11 @@ module.exports = function(css){
120128 // ;
121129 match ( / ^ [ ; \s ] * / ) ;
122130
123- return { property : prop , value : val } ;
131+ return {
132+ type : 'declaration' ,
133+ property : prop ,
134+ value : val
135+ } ;
124136 }
125137
126138 /**
@@ -139,6 +151,7 @@ module.exports = function(css){
139151 if ( ! vals . length ) return ;
140152
141153 return {
154+ type : 'keyframe' ,
142155 values : vals ,
143156 declarations : declarations ( )
144157 } ;
@@ -171,6 +184,7 @@ module.exports = function(css){
171184 if ( ! close ( ) ) return ;
172185
173186 return {
187+ type : 'keyframes' ,
174188 name : name ,
175189 vendor : vendor ,
176190 keyframes : frames
@@ -193,7 +207,11 @@ module.exports = function(css){
193207
194208 if ( ! close ( ) ) return ;
195209
196- return { supports : supports , rules : style } ;
210+ return {
211+ type : 'supports' ,
212+ supports : supports ,
213+ rules : style
214+ } ;
197215 }
198216
199217 /**
@@ -212,7 +230,11 @@ module.exports = function(css){
212230
213231 if ( ! close ( ) ) return ;
214232
215- return { media : media , rules : style } ;
233+ return {
234+ type : 'media' ,
235+ media : media ,
236+ rules : style
237+ } ;
216238 }
217239
218240 /**
@@ -231,15 +253,15 @@ module.exports = function(css){
231253
232254 // declarations
233255 var decl ;
234- while ( decl = declaration ( ) || atmargin ( ) ) {
256+ while ( decl = declaration ( ) ) {
235257 decls . push ( decl ) ;
236258 comments ( ) ;
237259 }
238260
239261 if ( ! close ( ) ) return ;
240262
241263 return {
242- type : " page" ,
264+ type : ' page' ,
243265 selectors : sel ,
244266 declarations : decls
245267 } ;
@@ -263,33 +285,19 @@ module.exports = function(css){
263285 if ( ! close ( ) ) return ;
264286
265287 return {
288+ type : 'document' ,
266289 document : doc ,
267290 vendor : vendor ,
268291 rules : style
269292 } ;
270293 }
271294
272- /**
273- * Parse margin at-rules
274- */
275-
276- function atmargin ( ) {
277- var m = match ( / ^ @ ( [ a - z \- ] + ) * / ) ;
278- if ( ! m ) return ;
279- var type = m [ 1 ]
280-
281- return {
282- type : type ,
283- declarations : declarations ( )
284- }
285- }
286-
287295 /**
288296 * Parse import
289297 */
290298
291299 function atimport ( ) {
292- return _atrule ( 'import' )
300+ return _atrule ( 'import' ) ;
293301 }
294302
295303 /**
@@ -315,7 +323,7 @@ module.exports = function(css){
315323 function _atrule ( name ) {
316324 var m = match ( new RegExp ( '^@' + name + ' *([^;\\n]+);\\s*' ) ) ;
317325 if ( ! m ) return ;
318- var ret = { }
326+ var ret = { type : name } ;
319327 ret [ name ] = m [ 1 ] . trim ( ) ;
320328 return ret ;
321329 }
@@ -364,7 +372,11 @@ module.exports = function(css){
364372 var sel = selector ( ) ;
365373 if ( ! sel ) return ;
366374 comments ( ) ;
367- return { selectors : sel , declarations : declarations ( ) } ;
375+ return {
376+ type : 'rule' ,
377+ selectors : sel ,
378+ declarations : declarations ( )
379+ } ;
368380 }
369381
370382 return stylesheet ( ) ;
0 commit comments