Skip to content

Commit d6d59c2

Browse files
committed
v0.0.5
2 parents 66381e3 + 89e46c1 commit d6d59c2

File tree

8 files changed

+105
-10
lines changed

8 files changed

+105
-10
lines changed

lib/csscomb.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Comb.prototype = {
3838
var handler = require('./options/' + option).setValue(config[option]);
3939
handler && _this._handlers.push(handler);
4040
} catch (e) {
41-
throw new Error('Handler ' + option + ' was not found.');
4241
}
4342
}
4443
});

lib/options/colon-space.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
* @returns {Object}
88
*/
99
setValue: function(value) {
10+
this._value = false;
1011
if (value === true) this._value = 'after';
1112
if (typeof value === 'string' && value.match(/after|before|both/)) this._value = value;
1213
if (!this._value) return;

lib/options/stick-brace.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
* @returns {Object}
88
*/
99
setValue: function(value) {
10+
this._value = false;
1011
if (value === true) value = ' ';
1112
if (typeof value === 'string' && value.match(/^[ \t\n]*$/)) this._value = value;
1213
if (!this._value) return;
@@ -19,9 +20,15 @@ module.exports = {
1920
* @param {node} node
2021
*/
2122
process: function(nodeType, node) {
22-
if (nodeType === 'simpleselector') {
23-
if (node[node.length - 1][0] === 's') node.pop();
24-
node.push(['s', this._value]);
23+
if (nodeType === 'selector') {
24+
for (var i = node.length; i--;) {
25+
var nodeItem = node[i];
26+
if (nodeItem[0] === 'simpleselector') {
27+
if (nodeItem[nodeItem.length - 1][0] === 's') nodeItem.pop();
28+
nodeItem.push(['s', this._value]);
29+
break;
30+
}
31+
}
2532
}
2633
}
2734

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "csscomb",
33
"description": "Tool for beautify CSS",
4-
"version": "0.0.4",
4+
"version": "0.0.5",
55
"homepage": "http://csscomb.com/",
66
"author": "Mikhail Troshev <mishanga@yandex-team.ru>",
77
"repository": "https://github.com/csscomb/csscomb.js",

test/integral.expect.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* Фигурные скобки. Вариант 1 */
2+
a, b, i /* foobar */
3+
{
4+
padding: 0;
5+
margin: 0;
6+
}
7+
div p
8+
{
9+
font-size: 1px;
10+
top: 0;
11+
}
12+
div p em
13+
{
14+
font-style: italic;
15+
border-bottom: 1px solid red;
16+
}
17+
18+
/* Фигурные скобки. Вариант 2 */
19+
div
20+
{
21+
padding: 0;
22+
margin: 0;
23+
}
24+
div p
25+
{
26+
font-size: 1px;
27+
top: 0;
28+
}
29+
div p em
30+
{
31+
font-style: italic;/* inline comment*/
32+
border-bottom: 1px solid red;
33+
}
34+
35+
/* Фигурные скобки. Вариант 3 */
36+
div
37+
{
38+
padding: 0;
39+
margin: 0;
40+
}
41+
/* foo */ div p
42+
{
43+
font-size: 1px;
44+
top: 0
45+
}
46+
div p em
47+
{
48+
/* upline comment*/
49+
font-style: italic;
50+
border-bottom: 1px solid red
51+
}
52+
53+
a
54+
{
55+
top: 0;/* ololo */margin: 0;}
56+
b
57+
{
58+
top: 0/* trololo */;margin: 0}

test/integral.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var Comb = require('../lib/csscomb');
2+
var assert = require('assert');
3+
var vow = require('vow');
4+
var vfs = require('vow-fs');
5+
6+
describe('integral test', function() {
7+
var comb;
8+
it('Process result must be equal to expect.css', function() {
9+
comb = new Comb();
10+
comb.configure(require('../.csscomb.json'));
11+
vow.all(['origin', 'expect'].map(function(type) {
12+
var fileName = './test/integral.' + type + '.css';
13+
return vfs.read(fileName, 'utf8').then(function(data) {
14+
return data;
15+
});
16+
}))
17+
.then(function(results) {
18+
try {
19+
assert.equal(comb.processString(results[0]), results[1]);
20+
done();
21+
} catch (e) {
22+
done(e);
23+
}
24+
});
25+
});
26+
});

test/test.css renamed to test/integral.origin.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Фигурные скобки. Вариант 1 */
2-
div{
2+
a, b, i /* foobar */ {
33
padding:0;
44
margin:0;
55
}
@@ -34,21 +34,21 @@ div {
3434
padding:0;
3535
margin:0;
3636
}
37-
div p {
37+
/* foo */ div p {
3838
font-size:1px;
39-
top:0;
39+
top:0
4040
}
4141
div p em {
4242
/* upline comment*/
4343
font-style:italic;
44-
border-bottom:1px solid red;
44+
border-bottom:1px solid red
4545
}
4646

4747
a{
4848
top: 0;/* ololo */margin :0;}
4949
b
5050
{
51-
top :0/* trololo */;margin : 0;}
51+
top :0/* trololo */;margin : 0}
5252

5353

5454

test/stick-brace.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ describe('options/stick-brace', function() {
1818
assert.equal(
1919
comb.processString(
2020
'a { color: red }' +
21+
'a,\nb /* i */\n{ color: red }' +
2122
'a{color:red}' +
2223
'a \t\t \n{color:red}' +
2324
'a /* foo */ {color:red}'
2425
),
2526
'a { color: red }' +
27+
'a,\nb /* i */ { color: red }' +
2628
'a {color:red}' +
2729
'a {color:red}' +
2830
'a /* foo */ {color:red}'
@@ -33,11 +35,13 @@ describe('options/stick-brace', function() {
3335
assert.equal(
3436
comb.processString(
3537
'a { color: red }' +
38+
'a, b /* i */ { color: red }' +
3639
'a{color:red}' +
3740
'a \t\t \n{color:red}' +
3841
'a /* foo */ {color:red}'
3942
),
4043
'a\n{ color: red }' +
44+
'a, b /* i */\n{ color: red }' +
4145
'a\n{color:red}' +
4246
'a\n{color:red}' +
4347
'a /* foo */\n{color:red}'

0 commit comments

Comments
 (0)