From c6bea7c51bb4508fe41293cd90702b7b7f26f726 Mon Sep 17 00:00:00 2001 From: Monica Kozbial Date: Mon, 21 Sep 2020 10:06:43 -0700 Subject: [PATCH] Call initsvg after loading field. (#4296) --- core/xml.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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');