With the 9 release field.getSourceBlock throws exception instead of returning a null if the source block is not connected yet.
Blockly.Blocks['generate_list_length'] = {
init: function() {
this.appendDummyInput()
.appendField("Length of")
.appendField(new Blockly.FieldDropdown(function() {
....
var source_block = this.getSourceBlock()
if (source_block) {
}
So I call the getSourceBlock in the dynamic options functions. However this dynamic option function seems to be already called before the SourceBlock is connected. Now I have to make a ugly code like:
try {
var source_block = this.getSourceBlock()
} catch (e) {
var source_block = null;
}
Is this on purpose, did I miss something?
Regards,
Koen