Skip to content

Instantly share code, notes, and snippets.

@sliekens
Created February 10, 2017 14:46
Show Gist options
  • Save sliekens/8fcaca516456d670780a5940b640001e to your computer and use it in GitHub Desktop.
Save sliekens/8fcaca516456d670780a5940b640001e to your computer and use it in GitHub Desktop.
function getSequentialFocusNavigationOrder(nodeList) {
var els = Array.prototype.slice.call(nodeList);
els = els.filter(e => e.tabIndex !== -1);
els = els.filter(e => !e.disabled);
els = els.sort(function(left, right) {
if (left.tabIndex === 0) {
if (right.tabIndex === 0) {
return 0;
}
return 1;
}
if (left.tabIndex === right.tabIndex) {
return 0;
}
if (left.tabIndex > right.tabIndex) {
return 1;
}
return -1;
});
return els;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment