From 9bab91762334f86c67a7c8f6e91550a9c3dd2f7f Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Tue, 2 Apr 2019 11:34:35 +0800 Subject: [PATCH] - Fix/Refactoring: Avoid missing item in loop, assuming it is possible and at least preventing lgtm warnings (lgtm.com-inspired) --- editor/jgraduate/jQuery.jPicker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/editor/jgraduate/jQuery.jPicker.js b/editor/jgraduate/jQuery.jPicker.js index 6067fcc0..494eb92d 100755 --- a/editor/jgraduate/jQuery.jPicker.js +++ b/editor/jgraduate/jQuery.jPicker.js @@ -2087,7 +2087,9 @@ const jPicker = function ($) { let html = ''; for (let i = 0; i < color.quickList.length; i++) { /* 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'); let ahex = color.quickList[i].val('ahex'); 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++) { if (List[i] === that) { List.splice(i, 1); + i--; // Decrement to ensure we don't miss next item (lgtm warning) } } }