From 75f32afcd513c94baececeb2d6414b43c27ed93b Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 24 Oct 2017 00:24:57 -0400 Subject: [PATCH] clean up excess code from generateGroupId --- lib/browser/api/menu.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index 82ecb08dab09..1effc3ff761f 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -188,20 +188,15 @@ Menu.buildFromTemplate = function (template) { // Search between separators to find a radio menu item and return its group id function generateGroupId (items, pos) { - let i, item if (pos > 0) { - let asc, start - for (start = pos - 1, i = start, asc = start <= 0; asc ? i <= 0 : i >= 0; asc ? i++ : i--) { - item = items[i] - if (item.type === 'radio') { return item.groupId } - if (item.type === 'separator') { break } + for (let idx = pos - 1; idx >= 0; idx--) { + if (items[idx].type === 'radio') return items[idx].groupId + if (items[idx].type === 'separator') break } } else if (pos < items.length) { - let asc1, end - for (i = pos, end = items.length - 1, asc1 = pos <= end; asc1 ? i <= end : i >= end; asc1 ? i++ : i--) { - item = items[i] - if (item.type === 'radio') { return item.groupId } - if (item.type === 'separator') { break } + for (let idx = pos; idx <= items.length - 1; idx++) { + if (items[idx].type === 'radio') return items[idx].groupId + if (items[idx].type === 'separator') break } } groupIdIndex += 1