Add warning message for unrecognized toolbox colour value. (PR #1881)

Fixes #1831
This commit is contained in:
Isabelle Taylor
2018-05-21 23:44:46 +01:00
committed by Andrew n marshall
parent c8b7b4a6a1
commit 629763e8ff

View File

@@ -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) {