Skip to content

Commit e56d812

Browse files
mariovalneyjdalton
authored andcommitted
Fix sort-order-fallback keep order
The new node (11.12.0) is changing the order if we do not return 0 to equal values in sort()
1 parent 08afce5 commit e56d812

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/options/sort-order.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,19 @@ module.exports = {
391391
if (a[2] !== b[2]) {
392392
// If unprefixed parts are different (i.e. `border` and
393393
// `color`), compare them:
394-
return a[2] <= b[2] ? -1 : 1;
395-
} else {
396-
// If unprefixed parts are identical (i.e. `border` in
397-
// `-moz-border` and `-o-border`), compare prefixes.
398-
// They should go in the same order they are set
399-
// in `prefixes` array.
400-
return prefixes.indexOf(a[1]) <= prefixes.indexOf(b[1]) ? -1 : 1;
394+
return a[2] < b[2] ? -1 : 1;
395+
}
396+
397+
// If unprefixed parts are identical (i.e. `border` in
398+
// `-moz-border` and `-o-border`), compare prefixes.
399+
// They should be untouched if they are equal:
400+
if (prefixes.indexOf(a[1]) === prefixes.indexOf(b[1])) {
401+
return 0;
401402
}
403+
404+
// They should go in the same order they are set
405+
// in `prefixes` array.
406+
return prefixes.indexOf(a[1]) < prefixes.indexOf(b[1]) ? -1 : 1;
402407
},
403408

404409
_sortNodes(nodes) {

0 commit comments

Comments
 (0)