diff --git a/mobile/chrome/content/browser-ui.js b/mobile/chrome/content/browser-ui.js index e131173b50b1..42003bedc8a3 100644 --- a/mobile/chrome/content/browser-ui.js +++ b/mobile/chrome/content/browser-ui.js @@ -1178,22 +1178,25 @@ var PageActions = { _updateAttributes: function _updateAttributes() { let container = document.getElementById("pageactions-container"); let visibleNodes = container.querySelectorAll("pageaction:not([hidden=true])"); - let len = visibleNodes.length; + let visibleCount = visibleNodes.length; let first = null, last = null; - for (let i = 0; i < len; i++) { + for (let i = 0; i < visibleCount; i++) { let node = visibleNodes[i]; node.removeAttribute("selector"); // Note: CSS indexes start at one, so even/odd are swapped. node.setAttribute("even", (i % 2) ? "true" : "false"); } - if (len >= 1) { + + if (visibleCount >= 1) { + visibleNodes[visibleCount - 1].setAttribute("selector", "last-child"); visibleNodes[0].setAttribute("selector", "first-child"); - visibleNodes[len-1].setAttribute("selector", "last-child"); } - if (len >= 2) { + + if (visibleCount >= 2) { + visibleNodes[visibleCount - 2].setAttribute("selector", "second-last-child"); + visibleNodes[0].setAttribute("selector", "first-child"); visibleNodes[1].setAttribute("selector", "second-child"); - visibleNodes[len-2].setAttribute("selector", "second-last-child"); } } };