Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Priority order is not being honored #35

Open
mwhebert opened this issue Sep 20, 2017 · 0 comments
Open

Priority order is not being honored #35

mwhebert opened this issue Sep 20, 2017 · 0 comments

Comments

@mwhebert
Copy link

Looks like the findAttributesPattern function is not properly sorting the attributes by the priority array properly. Looks like the sort comparison check is not correct. changing the sort code to this below seemed to resolve the issue

var outsidePriority = priority.length + 1; // greater than any priority position
var sortedKeys = Object.keys(attributes).sort(function (curr, next) {
var currPos = priority.indexOf(attributes[curr].name);
var nextPos = priority.indexOf(attributes[next].name);

if (nextPos == -1) nextPos = outsidePriority;
if (currPos == -1) currPos = outsidePriority;

if (nextPos > currPos) { return -1;}
if (nextPos < currPos) { return 1;}
return 0;

/* old code
if (nextPos === -1) {
if (currPos === -1) {
return 0;
}
return -1;
}
return currPos - nextPos;
*/
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant