From e56d8120d72c4d8afda550b7e777904296c7409d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Valney?= Date: Wed, 27 Mar 2019 10:38:26 -0300 Subject: [PATCH] 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() --- src/options/sort-order.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/options/sort-order.js b/src/options/sort-order.js index 27a2198a..482e0259 100644 --- a/src/options/sort-order.js +++ b/src/options/sort-order.js @@ -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) {