Skip to content

Commit

Permalink
[options] sort-order: properties of the same name should stay in the …
Browse files Browse the repository at this point in the history
…same order
  • Loading branch information
haoqunjiang authored and tonyganch committed Jul 11, 2016
1 parent 3176bad commit e38930e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/options/sort-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,13 @@ module.exports = {
if (a[2] !== b[2]) {
// If unprefixed parts are different (i.e. `border` and
// `color`), compare them:
return a[2] < b[2] ? -1 : 1;
return a[2] <= b[2] ? -1 : 1;
} else {
// If unprefixed parts are identical (i.e. `border` in
// `-moz-border` and `-o-border`), compare prefixes.
// They should go in the same order they are set
// in `prefixes` array.
return prefixes.indexOf(a[1]) < prefixes.indexOf(b[1]) ? -1 : 1;
return prefixes.indexOf(a[1]) <= prefixes.indexOf(b[1]) ? -1 : 1;
}
},

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
button {
outline: 1px dotted;
outline: 5px auto -webkit-focus-ring-color;
}
10 changes: 9 additions & 1 deletion test/options/sort-order-fallback/process/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ describe('Option `sort-order-fallback`, process', function() {
return test.shouldBeEqual('test.css', 'test-2.expected.css');
});

it('Properties of the same name should stay in the same order', function() {
let config = {
'sort-order': ['...'],
'sort-order-fallback': 'abc'
};
let test = new Test(this, config);
return test.shouldBeEqual('same-property.css');
});

it('Should leave leftovers as is if `sort-order-fallback` is not set', function() {
let config = {
'sort-order': ['top', 'left']
Expand All @@ -33,4 +42,3 @@ describe('Option `sort-order-fallback`, process', function() {
});
});
});

0 comments on commit e38930e

Please sign in to comment.