Skip to content

Commit

Permalink
Fix inconsistent css variable sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed May 8, 2019
1 parent 070f9e5 commit 8fc6122
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/_util/helpers.js
Expand Up @@ -139,7 +139,18 @@ export function sortCss(cssText) {
return cssText.split(';')
.filter(Boolean)
.map(s => s.replace(/^\s+|\s+$/g, '').replace(/(\s*:\s*)/g, ': '))
.sort((a, b) => a[0]==='-' ? -1 : b[0]==='-' ? 1 : a.localeCompare(b))
.sort((a, b) => {
// CSS Variables are typically positioned at the start
if (a[0]==='-') {
// If both are a variable we just compare them
if (b[0]==='-') return a.localeCompare(b);
return -1;
}
// b is a css var
if (b[0]==='-') return 1;

return a.localeCompare(b);
})
.join('; ') + ';';
}

Expand Down

0 comments on commit 8fc6122

Please sign in to comment.