From 629763e8ffb53e6c7f97053e67b1d86992aa4177 Mon Sep 17 00:00:00 2001 From: Isabelle Taylor Date: Mon, 21 May 2018 23:44:46 +0100 Subject: [PATCH] Add warning message for unrecognized toolbox colour value. (PR #1881) Fixes #1831 --- core/toolbox.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/toolbox.js b/core/toolbox.js index 4ea684723..a0e692a2d 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -334,15 +334,15 @@ Blockly.Toolbox.prototype.syncTrees_ = function(treeIn, treeOut, pathToMedia) { // (eg. `%{BKY_MATH_HUE}`). var colour = Blockly.utils.replaceMessageReferences( childIn.getAttribute('colour')); - if (goog.isString(colour)) { - if (/^#[0-9a-fA-F]{6}$/.test(colour)) { - childOut.hexColour = colour; - } else { - childOut.hexColour = Blockly.hueToRgb(Number(colour)); - } + if (/^#[0-9a-fA-F]{6}$/.test(colour)) { + childOut.hexColour = colour; + this.hasColours_ = true; + } else if (!isNaN(Number(colour))) { + childOut.hexColour = Blockly.hueToRgb(Number(colour)); this.hasColours_ = true; } else { childOut.hexColour = ''; + console.warn('Toolbox category "' + categoryName + '" has unrecognized colour attribute: ' + colour); } if (childIn.getAttribute('expanded') == 'true') { if (childOut.blocks.length) {