Skip to content

Commit

Permalink
Fix sort-order-fallback keep order
Browse files Browse the repository at this point in the history
The new node (11.12.0) is changing the order if we do not return 0 to equal values in sort()
  • Loading branch information
mariovalney authored and jdalton committed Apr 18, 2019
1 parent 08afce5 commit e56d812
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/options/sort-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,19 @@ 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;
} 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 a[2] < b[2] ? -1 : 1;
}

// If unprefixed parts are identical (i.e. `border` in
// `-moz-border` and `-o-border`), compare prefixes.
// They should be untouched if they are equal:
if (prefixes.indexOf(a[1]) === prefixes.indexOf(b[1])) {
return 0;
}

// They should go in the same order they are set
// in `prefixes` array.
return prefixes.indexOf(a[1]) < prefixes.indexOf(b[1]) ? -1 : 1;
},

_sortNodes(nodes) {
Expand Down

0 comments on commit e56d812

Please sign in to comment.