@@ -11,8 +11,6 @@ module.exports = Compiler;
11
11
12
12
function Compiler ( options ) {
13
13
options = options || { } ;
14
- this . compress = options . compress ;
15
- this . indentation = options . indent ;
16
14
}
17
15
18
16
/**
@@ -22,7 +20,7 @@ function Compiler(options) {
22
20
Compiler . prototype . compile = function ( node ) {
23
21
return node . stylesheet
24
22
. rules . map ( this . visit , this )
25
- . join ( this . compress ? '' : '\n\n ') ;
23
+ . join ( ' ') ;
26
24
} ;
27
25
28
26
/**
@@ -39,7 +37,6 @@ Compiler.prototype.visit = function(node){
39
37
40
38
Compiler . prototype . comment = function ( node ) {
41
39
if ( this . compress ) return '' ;
42
- return this . indent ( ) + '/*' + node . comment + '*/' ;
43
40
} ;
44
41
45
42
/**
@@ -55,21 +52,11 @@ Compiler.prototype.import = function(node){
55
52
*/
56
53
57
54
Compiler . prototype . media = function ( node ) {
58
- if ( this . compress ) {
59
- return '@media '
60
- + node . media
61
- + '{'
62
- + node . rules . map ( this . visit , this ) . join ( '' )
63
- + '}' ;
64
- }
65
-
66
55
return '@media '
67
56
+ node . media
68
- + ' {\n'
69
- + this . indent ( 1 )
70
- + node . rules . map ( this . visit , this ) . join ( '\n\n' )
71
- + this . indent ( - 1 )
72
- + '\n}' ;
57
+ + '{'
58
+ + node . rules . map ( this . visit , this ) . join ( '' )
59
+ + '}' ;
73
60
} ;
74
61
75
62
/**
@@ -79,31 +66,18 @@ Compiler.prototype.media = function(node){
79
66
Compiler . prototype . document = function ( node ) {
80
67
var doc = '@' + ( node . vendor || '' ) + 'document ' + node . document ;
81
68
82
- if ( this . compress ) {
83
- return doc
84
- + '{'
85
- + node . rules . map ( this . visit , this ) . join ( '' )
86
- + '}' ;
87
- }
88
-
89
- return doc + ' '
90
- + ' {\n'
91
- + this . indent ( 1 )
92
- + node . rules . map ( this . visit , this ) . join ( '\n\n' )
93
- + this . indent ( - 1 )
94
- + '\n}' ;
69
+ return doc
70
+ + '{'
71
+ + node . rules . map ( this . visit , this ) . join ( '' )
72
+ + '}' ;
95
73
} ;
96
74
97
75
/**
98
76
* Visit charset node.
99
77
*/
100
78
101
79
Compiler . prototype . charset = function ( node ) {
102
- if ( this . compress ) {
103
- return '@charset ' + node . charset + ';' ;
104
- }
105
-
106
- return '@charset ' + node . charset + ';\n' ;
80
+ return '@charset ' + node . charset + ';' ;
107
81
} ;
108
82
109
83
/**
@@ -125,24 +99,12 @@ Compiler.prototype.supports = function(node){
125
99
*/
126
100
127
101
Compiler . prototype . keyframes = function ( node ) {
128
- if ( this . compress ) {
129
- return '@'
130
- + ( node . vendor || '' )
131
- + 'keyframes '
132
- + node . name
133
- + '{'
134
- + node . keyframes . map ( this . visit , this ) . join ( '' )
135
- + '}' ;
136
- }
137
-
138
102
return '@'
139
103
+ ( node . vendor || '' )
140
104
+ 'keyframes '
141
105
+ node . name
142
- + ' {\n'
143
- + this . indent ( 1 )
144
- + node . keyframes . map ( this . visit , this ) . join ( '\n' )
145
- + this . indent ( - 1 )
106
+ + '{'
107
+ + node . keyframes . map ( this . visit , this ) . join ( '' )
146
108
+ '}' ;
147
109
} ;
148
110
@@ -153,20 +115,10 @@ Compiler.prototype.keyframes = function(node){
153
115
Compiler . prototype . keyframe = function ( node ) {
154
116
var decls = node . declarations ;
155
117
156
- if ( this . compress ) {
157
- return node . values . join ( ',' )
158
- + '{'
159
- + decls . map ( this . visit , this ) . join ( '' )
160
- + '}' ;
161
- }
162
-
163
- return this . indent ( )
164
- + node . values . join ( ', ' )
165
- + ' {\n'
166
- + this . indent ( 1 )
167
- + decls . map ( this . visit , this ) . join ( '\n' )
168
- + this . indent ( - 1 )
169
- + '\n' + this . indent ( ) + '}\n' ;
118
+ return node . values . join ( ',' )
119
+ + '{'
120
+ + decls . map ( this . visit , this ) . join ( '' )
121
+ + '}' ;
170
122
} ;
171
123
172
124
/**
@@ -191,49 +143,20 @@ Compiler.prototype.page = function(node){
191
143
*/
192
144
193
145
Compiler . prototype . rule = function ( node ) {
194
- var indent = this . indent ( ) ;
195
146
var decls = node . declarations ;
147
+ if ( ! decls . length ) return '' ;
196
148
197
- if ( this . compress ) {
198
- if ( ! decls . length ) return '' ;
199
-
200
- return node . selectors . join ( ',' )
201
- + '{'
202
- + decls . map ( this . visit , this ) . join ( '' )
203
- + '}' ;
204
- }
205
-
206
- return node . selectors . map ( function ( s ) { return indent + s } ) . join ( ',\n' )
207
- + ' {\n'
208
- + this . indent ( 1 )
209
- + decls . map ( this . visit , this ) . join ( '\n' )
210
- + this . indent ( - 1 )
211
- + '\n' + this . indent ( ) + '}' ;
149
+ return node . selectors . join ( ',' )
150
+ + '{'
151
+ + decls . map ( this . visit , this ) . join ( '' )
152
+ + '}' ;
212
153
} ;
213
154
214
155
/**
215
156
* Visit declaration node.
216
157
*/
217
158
218
159
Compiler . prototype . declaration = function ( node ) {
219
- if ( this . compress ) {
220
- return node . property + ':' + node . value + ';' ;
221
- }
222
-
223
- return this . indent ( ) + node . property + ': ' + node . value + ';' ;
160
+ return node . property + ':' + node . value + ';' ;
224
161
} ;
225
162
226
- /**
227
- * Increase, decrease or return current indentation.
228
- */
229
-
230
- Compiler . prototype . indent = function ( level ) {
231
- this . level = this . level || 1 ;
232
-
233
- if ( null != level ) {
234
- this . level += level ;
235
- return '' ;
236
- }
237
-
238
- return Array ( this . level ) . join ( this . indentation || ' ' ) ;
239
- } ;
0 commit comments