Skip to content

Commit

Permalink
fix sort targets #119
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Oct 17, 2017
1 parent 6670b91 commit e71dee8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions flat/style/flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,12 @@ function auto_grow(element) {

function sort_targets(targets) {
//Sort a list of target IDs (words only) so that they are in proper order of appearance
var sameparent = false;

var commonancestors = [];
if ((targets.length > 0) && (structure[targets[0]]) && (structure[targets[0]].parent) && (structure[structure[targets[0]].parent].structure)) {
sameparent = structure[targets[0]].parent;
for (var i = 1; i < targets.length; i++) {
if (structure[targets[0]].parent != sameparent) {
if (structure[targets[i]].parent != sameparent) {
sameparent = false;
break;
}
Expand All @@ -751,7 +752,7 @@ function sort_targets(targets) {
});
}
if (sortedtargets.length != targets.length) {
throw "Error, unable to sort targets, expected " + targets.length + ", got " + sortedtargets.length;
throw "Error, unable to sort targets, expected " + targets.length + ", got " + sortedtargets.length + ", sameparent=" + sameparent;
}
return sortedtargets;
}
Expand Down

0 comments on commit e71dee8

Please sign in to comment.