1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-18 11:05:41 +01:00

non-checkboxes have higher priority in limits

This commit is contained in:
Kyle Spearrin 2017-10-26 09:19:18 -04:00
parent a2480bf2df
commit 9488b48915

View File

@ -562,7 +562,25 @@
els = Array.prototype.slice.call(elsList);
} catch (e) { }
return limit && els.length > limit ? els.slice(0, limit) : els;
if (!limit || els.length <= limit) {
return els;
}
// non-checkboxes have higher priority
els = els.sort(function (a, b) {
var aType = a.type ? a.type.toLowerCase() : a.type;
var bType = b.type ? b.type.toLowerCase() : b.type;
if (aType !== 'checkbox' && bType === 'checkbox') {
return -1;
}
if (aType === 'checkbox' && bType !== 'checkbox') {
return 1;
}
return 0;
});
return els.slice(0, limit);
// END MODIFICATION
}