mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
Fix invalid colours in Block Factory.
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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/');");
|
||||
|
||||
Reference in New Issue
Block a user