From 9488b489155eb6429f82e89d5e5d281cf082d8fb Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 26 Oct 2017 09:19:18 -0400 Subject: [PATCH] non-checkboxes have higher priority in limits --- src/content/autofill.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/content/autofill.js b/src/content/autofill.js index 841eaefdc10..13d450c3e5f 100644 --- a/src/content/autofill.js +++ b/src/content/autofill.js @@ -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 }