diff --git a/core/xml.js b/core/xml.js index 20c82015b..6fa10c5a3 100644 --- a/core/xml.js +++ b/core/xml.js @@ -651,6 +651,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { } } + var callInitSvg = false; var name = xmlChild.getAttribute('name'); var xmlChildElement = /** @type {!Element} */ (xmlChild); switch (xmlChild.nodeName.toLowerCase()) { @@ -660,7 +661,7 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { block.domToMutation(xmlChildElement); if (block.initSvg) { // Mutation may have added some elements that need initializing. - block.initSvg(); + callInitSvg = true; } } break; @@ -748,6 +749,11 @@ Blockly.Xml.domToBlockHeadless_ = function(xmlBlock, workspace) { } } + if (callInitSvg) { + // InitSvg needs to be called after variable fields are loaded. + block.initSvg(); + } + var inline = xmlBlock.getAttribute('inline'); if (inline) { block.setInputsInline(inline == 'true');