Skip to content

Commit d03a867

Browse files
committed
Empty string should be a valid value for stick-brace option
1 parent 680f006 commit d03a867

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

lib/options/stick-brace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
if (value === true) this._value = ' ';
1212
if (typeof value === 'number' && value === Math.abs(Math.round(value)))
1313
this._value = new Array(value + 1).join(' ');
14-
if (typeof value === 'string' && value.match(/^[ \t\n]+$/)) this._value = value;
14+
if (typeof value === 'string' && value.match(/^[ \t\n]*$/)) this._value = value;
1515
if (typeof this._value === 'string') return this;
1616
},
1717

test/stick-brace.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ describe('options/stick-brace', function() {
4444
'@media all\n{ .input__control\n{ color: #000;\n \n }\t}'
4545
);
4646
});
47+
it('Empty String value should set no space before brace', function() {
48+
comb.configure({ 'stick-brace': '' });
49+
assert.equal(
50+
comb.processString(
51+
'a{ color: red }' +
52+
'a, b /* i */ { color: red; }' +
53+
'a \t\t \n{color:red\n \n}' +
54+
'a /* foo */ {color:red ;\n}' +
55+
'@media all { .input__control { color: #000;\n \n }\t}'
56+
),
57+
'a{ color: red }' +
58+
'a, b /* i */{ color: red; }' +
59+
'a{color:red\n \n}' +
60+
'a /* foo */{color:red ;\n}' +
61+
'@media all{ .input__control{ color: #000;\n \n }\t}'
62+
);
63+
});
4764

4865
// Helper to check the detection
4966
function should_detect(options, a, b) {

0 commit comments

Comments
 (0)