[fix] StyleSheet group sorting

Close #1356
This commit is contained in:
Giuseppe Gurgone
2019-06-01 18:21:39 +02:00
committed by Nicolas Gallagher
parent 33dc3cb018
commit 29146fe5bc
3 changed files with 12 additions and 3 deletions
@@ -24,7 +24,13 @@ exports[`createOrderedCSSStyleSheet #insert insertion order for different groups
.four-2 {}
[stylesheet-group=\\"9.9\\"]{}
.nine-1 {}
.nine-2 {}"
.nine-2 {}
[stylesheet-group=\\"10\\"]{}
.ten {}
[stylesheet-group=\\"20\\"]{}
.twenty {}
[stylesheet-group=\\"20.2\\"]{}
.twenty-point2 {}"
`;
exports[`createOrderedCSSStyleSheet #insert insertion order for same group 1`] = `""`;
@@ -54,6 +54,9 @@ describe('createOrderedCSSStyleSheet', () => {
sheet.insert('.two {}', 2.2);
sheet.insert('.four-1 {}', 4);
sheet.insert('.four-2 {}', 4);
sheet.insert('.twenty {}', 20);
sheet.insert('.ten {}', 10);
sheet.insert('.twenty-point2 {}', 20.2);
expect(sheet.getTextContent()).toMatchSnapshot();
});
@@ -148,8 +148,8 @@ function decodeGroupRule(cssRule) {
function getOrderedGroups(obj: { [key: number]: any }) {
return Object.keys(obj)
.sort()
.map(k => Number(k));
.map(Number)
.sort((a, b) => (a > b ? 1 : -1));
}
const pattern = /\s*([,])\s*/g;