Skip to content

Commit 9c2b60a

Browse files
committed
Лишние переносы строк "stick-brace": "\n" (close #19)
1 parent ebff12d commit 9c2b60a

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

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

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)