Skip to content

Commit 0f352bf

Browse files
committed
Merge pull request #131 from csscomb/tg/127-sort-order-value
Sort order: Make array of strings an acceptable value (#127)
2 parents df133d6 + 3f91387 commit 0f352bf

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

lib/options/sort-order.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ module.exports = {
1010
if (!value) return;
1111

1212
this._order = {};
13-
value.forEach(function(group, groupIndex) {
14-
group.forEach(function(prop, propIndex) {
15-
this._order[prop] = { group: groupIndex, prop: propIndex };
13+
14+
if (typeof value[0] === 'string') {
15+
value.forEach(function(prop, propIndex) {
16+
this._order[prop] = { group: 0, prop: propIndex };
17+
}, this);
18+
} else {
19+
value.forEach(function(group, groupIndex) {
20+
group.forEach(function(prop, propIndex) {
21+
this._order[prop] = { group: groupIndex, prop: propIndex };
22+
}, this);
1623
}, this);
17-
}, this);
24+
}
1825

1926
return this;
2027
},

test/sort-order.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ describe('options/sort-order', function() {
1313
comb = new Comb();
1414
});
1515

16+
it('Should be in expected order in case properties are not grouped', function() {
17+
var config = { 'sort-order': ['position', 'z-index'] };
18+
19+
var input = readFile('single-group.css');
20+
var expected = readFile('single-group.expected.css');
21+
22+
comb.configure(config);
23+
assert.equal(comb.processString(input), expected);
24+
});
25+
1626
it('Should be in expected order in case of 1 group', function() {
1727
var config = { 'sort-order': [
1828
['position', 'z-index']

0 commit comments

Comments
 (0)