- Fix/Refactoring: Avoid missing item in loop, assuming it is possible and at least preventing lgtm warnings (lgtm.com-inspired)

master
Brett Zamir 2019-04-02 11:34:35 +08:00
parent 1ae6e91bb0
commit 9bab917623
1 changed files with 4 additions and 1 deletions

View File

@ -2087,7 +2087,9 @@ const jPicker = function ($) {
let html = ''; let html = '';
for (let i = 0; i < color.quickList.length; i++) { for (let i = 0; i < color.quickList.length; i++) {
/* if default colors are hex strings, change them to color objects */ /* if default colors are hex strings, change them to color objects */
if ((typeof (color.quickList[i])).toString().toLowerCase() === 'string') color.quickList[i] = new Color({hex: color.quickList[i]}); if ((typeof (color.quickList[i])).toString().toLowerCase() === 'string') {
color.quickList[i] = new Color({hex: color.quickList[i]});
}
const alpha = color.quickList[i].val('a'); const alpha = color.quickList[i].val('a');
let ahex = color.quickList[i].val('ahex'); let ahex = color.quickList[i].val('ahex');
if (!win.alphaSupport && ahex) ahex = ahex.substring(0, 6) + 'ff'; if (!win.alphaSupport && ahex) ahex = ahex.substring(0, 6) + 'ff';
@ -2167,6 +2169,7 @@ const jPicker = function ($) {
for (let i = 0; i < List.length; i++) { for (let i = 0; i < List.length; i++) {
if (List[i] === that) { if (List[i] === that) {
List.splice(i, 1); List.splice(i, 1);
i--; // Decrement to ensure we don't miss next item (lgtm warning)
} }
} }
} }