Skip to content

Commit 1f27f9e

Browse files
committed
Fix error when sorting leftover variable definitions. [closes #443]
1 parent cbd6815 commit 1f27f9e

File tree

6 files changed

+23
-2
lines changed

6 files changed

+23
-2
lines changed

src/options/sort-order.js

+8
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,14 @@ module.exports = {
385385
a = a.node.first().first().content;
386386
b = b.node.first().first().content;
387387

388+
if (Array.isArray(a)) {
389+
a = a[0].content;
390+
}
391+
392+
if (Array.isArray(b)) {
393+
b = b[0].content;
394+
}
395+
388396
// Get prefix and unprefixed part. For example:
389397
// ['-o-animation', '-o-', 'animation']
390398
// ['color', '', 'color']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
div {$blue: steelblue; $red: tomato; }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
div {$red: tomato; $blue: steelblue; }

test/options/sort-order-fallback/process/test.js

+11
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,15 @@ describe('Option `sort-order-fallback`, process', function() {
4141
return test.shouldBeEqual('test.css', 'test-3.expected.css');
4242
});
4343
});
44+
45+
describe('scss', function() {
46+
it('Should sort leftover variables alphabetically', function() {
47+
let config = {
48+
'sort-order': [],
49+
'sort-order-fallback': 'abc'
50+
};
51+
let test = new Test(this, config);
52+
return test.shouldBeEqual('leftovers-variable.scss', 'leftovers-variable.expected.scss');
53+
});
54+
});
4455
});
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
div {$red: tomato; color: $tomato; }
1+
div {$red: tomato; color: $red; }
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
div { color: $tomato; $red: tomato; }
1+
div { color: $red; $red: tomato; }

0 commit comments

Comments
 (0)