Skip to content

Commit 13d8865

Browse files
committed
Merge pull request #12 from csscomb/stick-brace
Option: stick-brace
2 parents 2692dd2 + 9fce05d commit 13d8865

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/options/stick-brace.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
3+
_value: false,
4+
5+
/**
6+
* Sets handler value.
7+
*
8+
* @param {String|Number|Boolean} value Option value
9+
* @returns {Object}
10+
*/
11+
setValue: function(value) {
12+
if (!value) return this;
13+
if (value === true) value = ' '; // 1 space by default
14+
if (typeof value === 'number') this._value = new Array(Math.round(value) + 1).join(' ');
15+
if (typeof value === 'string' && value.match(/^[ \t\n]*$/)) this._value = value;
16+
return this;
17+
},
18+
19+
/**
20+
* Processes tree node.
21+
* @param {String} nodeType
22+
* @param {node} node
23+
*/
24+
process: function(nodeType, node) {
25+
if (nodeType === 'simpleselector') {
26+
if (node[node.length - 1][0] === 's') node.pop();
27+
node.push(['s', this._value]);
28+
}
29+
}
30+
31+
};

test/test.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ div {
4646

4747
a{
4848
top: 0;/* ololo */margin :0;}
49-
b{
49+
b
50+
{
5051
top :0/* trololo */;margin : 0;}
5152

5253

0 commit comments

Comments
 (0)