Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911)

This commit is contained in:
Andrew n marshall
2017-02-06 14:15:20 -08:00
committed by GitHub
parent 680fc4b6d3
commit 24ebbcaad0
3 changed files with 60 additions and 5 deletions

View File

@@ -405,9 +405,15 @@ Blockly.jsonInitFactory_ = function(jsonDef) {
*/
Blockly.defineBlocksWithJsonArray = function(jsonArray) {
for (var i = 0, elem; elem = jsonArray[i]; i++) {
Blockly.Blocks[elem.type] = {
init: Blockly.jsonInitFactory_(elem)
};
var typename = elem.type;
if (typename == null || typename === '') {
console.warn('Block definition #' + i +
' in JSON array is missing a type attribute. Skipping.');
} else {
Blockly.Blocks[typename] = {
init: Blockly.jsonInitFactory_(elem)
};
}
}
};