Skip to content

Commit ee68d4b

Browse files
committed
fix trailing ; with comments within rules
1 parent bb2d6a3 commit ee68d4b

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,20 @@ Compiler.prototype.keyframes = function(node){
144144
*/
145145

146146
Compiler.prototype.keyframe = function(node){
147+
var decls = node.declarations;
148+
147149
if (this.compress) {
148150
return node.values.join(',')
149151
+ '{'
150-
+ node.declarations.map(this.declaration, this).join(';')
152+
+ decls.map(this.visit, this).join('')
151153
+ '}';
152154
}
153155

154156
return this.indent()
155157
+ node.values.join(', ')
156158
+ ' {\n'
157159
+ this.indent(1)
158-
+ node.declarations.map(this.declaration, this).join(';\n')
160+
+ decls.map(this.visit, this).join('\n')
159161
+ this.indent(-1)
160162
+ '\n' + this.indent() + '}\n';
161163
};
@@ -168,7 +170,7 @@ Compiler.prototype.page = function(node){
168170
return '@page ' + node.selectors.join(', ')
169171
+ ' {\n'
170172
+ this.indent(1)
171-
+ node.declarations.map(this.declaration, this).join(';\n')
173+
+ node.declarations.map(this.visit, this).join('\n')
172174
+ this.indent(-1)
173175
+ '\n}';
174176
};
@@ -186,14 +188,14 @@ Compiler.prototype.rule = function(node){
186188

187189
return node.selectors.join(',')
188190
+ '{'
189-
+ decls.map(this.visit, this).join(';')
191+
+ decls.map(this.visit, this).join('')
190192
+ '}';
191193
}
192194

193195
return node.selectors.map(function(s){ return indent + s }).join(',\n')
194196
+ ' {\n'
195197
+ this.indent(1)
196-
+ decls.map(this.visit, this).join(';\n')
198+
+ decls.map(this.visit, this).join('\n')
197199
+ this.indent(-1)
198200
+ '\n' + this.indent() + '}';
199201
};
@@ -204,10 +206,10 @@ Compiler.prototype.rule = function(node){
204206

205207
Compiler.prototype.declaration = function(node){
206208
if (this.compress) {
207-
return node.property + ':' + node.value;
209+
return node.property + ':' + node.value + ';';
208210
}
209211

210-
return this.indent() + node.property + ': ' + node.value;
212+
return this.indent() + node.property + ': ' + node.value + ';';
211213
};
212214

213215
/**

test/cases/document.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
@-moz-document url-prefix() {
22
.icon-spin {
3-
height: .9em
3+
height: .9em;
44
}
55

66
.btn .icon-spin {
7-
height: auto
7+
height: auto;
88
}
99

1010
.icon-spin.icon-large {
11-
height: 1.25em
11+
height: 1.25em;
1212
}
1313

1414
.btn .icon-spin.icon-large {
15-
height: .75em
15+
height: .75em;
1616
}
1717
}

test/cases/keyframes.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@keyframes fade {
22
from {
33
opacity: 0;
4-
opacity: 1
4+
opacity: 1;
55
}
66

77
to {
8-
opacity: 1
8+
opacity: 1;
99
}
10-
}
10+
}

test/cases/media.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
@media screen, projection {
22
html {
33
background: #fffef0;
4-
color: #300
4+
color: #300;
55
}
66

77
body {
88
max-width: 35em;
9-
margin: 0 auto
9+
margin: 0 auto;
1010
}
1111
}
1212

1313
@media print {
1414
html {
1515
background: #fff;
16-
color: #000
16+
color: #000;
1717
}
1818

1919
body {
2020
padding: 1in;
21-
border: 0.5pt solid #666
21+
border: 0.5pt solid #666;
2222
}
23-
}
23+
}

test/cases/rules.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
tobi {
22
name: 'tobi';
3-
age: 2
3+
age: 2;
44
}
55

66
loki {
77
name: 'loki';
8-
age: 1
9-
}
8+
age: 1;
9+
}

test/cases/selectors.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
foo,
22
bar,
33
baz {
4-
color: 'black'
5-
}
4+
color: 'black';
5+
}

0 commit comments

Comments
 (0)