Fix invalid colours in Block Factory.

This commit is contained in:
Neil Fraser
2016-02-26 21:20:39 -08:00
parent b567d6b0d7
commit a22b936229
2 changed files with 7 additions and 2 deletions

View File

@@ -696,7 +696,10 @@ Blockly.Blocks['colour_hue'] = {
},
validator: function(text) {
// Update the current block's colour to match.
this.sourceBlock_.setColour(text);
var hue = parseInt(text, 10);
if (!isNaN(hue)) {
this.sourceBlock_.setColour(hue);
}
},
mutationToDom: function(workspace) {
var container = document.createElement('mutation');

View File

@@ -258,7 +258,9 @@ function formatJavaScript_(blockType, rootBlock) {
var colourBlock = rootBlock.getInputTargetBlock('COLOUR');
if (colourBlock && !colourBlock.disabled) {
var hue = parseInt(colourBlock.getFieldValue('HUE'), 10);
code.push(' this.setColour(' + hue + ');');
if (!isNaN(hue)) {
code.push(' this.setColour(' + hue + ');');
}
}
code.push(" this.setTooltip('');");
code.push(" this.setHelpUrl('http://www.example.com/');");