Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into upgrade-yargs
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Oct 13, 2020
2 parents 298064f + 57e291e commit 0f08287
Show file tree
Hide file tree
Showing 6 changed files with 5,242 additions and 5,225 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -3,10 +3,12 @@ language: node_js
sudo: false

node_js:
- "14"
- "13"
- "12"
- "11"
- "10"
- "8"
- "6"

script:
- npm test
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
@@ -1,9 +1,10 @@
# Test against this versions of Node.js
environment:
matrix:
- nodejs_version: 14
- nodejs_version: 12
- nodejs_version: 10
- nodejs_version: 8
- nodejs_version: 6

# Install scripts. (runs after repo cloning)
install:
Expand Down
21 changes: 20 additions & 1 deletion lib/carto/parser.js
Expand Up @@ -244,6 +244,10 @@ carto.Parser = function Parser(env) {

// Sort rules by specificity: this function expects selectors to be
// split already.
// If the specifity is equal, the definition is compared by the elements
// array. Definitions with more elements are 'larger', and definitions
// with the same number of elements are sorted alphabetically.
// If the elements are also equal, the zoom level of the definition is compared
//
// Written to be used as a .sort(Function);
// argument.
Expand All @@ -256,7 +260,22 @@ carto.Parser = function Parser(env) {
if (as[0] != bs[0]) return bs[0] - as[0];
if (as[1] != bs[1]) return bs[1] - as[1];
if (as[2] != bs[2]) return bs[2] - as[2];
return bs[3] - as[3];
if (bs[3] != as[3]) return bs[3] - as[3];

// The definition with the most elements is 'larger'
if (a.elements.length != b.elements.length) return b.elements.length - a.elements.length;

// Sort based on the alphabetic order of each element
for (var i = 0; i < a.elements.length; i++) {
if (a.elements[i] != b.elements[i]) {
return a.elements[i].value.localeCompare(b.elements[i].value);
}
}

if (a.zoom != b.zoom) return b.zoom - a.zoom;

// Order is not defined
return 0;
};

return root;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -30,7 +30,7 @@
"man": "./man/carto.1",
"main": "./lib/carto/index",
"engines": {
"node": ">=0.5.x"
"node": ">=8.0.0"
},
"dependencies": {
"chroma-js": "~1.3.5",
Expand Down

0 comments on commit 0f08287

Please sign in to comment.