From 8c94a16bc6e34f63eacb291e7d78baa87711e48f Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Fri, 10 Jun 2016 18:19:25 -0700 Subject: [PATCH] Fix error when undoing a shadow block replacement. Issue #415. --- core/xml.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/xml.js b/core/xml.js index f2664ac76..70fd915a5 100644 --- a/core/xml.js +++ b/core/xml.js @@ -294,7 +294,11 @@ Blockly.Xml.domToWorkspace = function(xml, workspace) { for (var i = 0; i < childCount; i++) { var xmlChild = xml.childNodes[i]; var name = xmlChild.nodeName.toLowerCase(); - if (name == 'block') { + if (name == 'block' || + (name == 'shadow' && !Blockly.Events.recordUndo)) { + // Allow top-level shadow blocks if recordUndo is disabled since + // that means an undo is in progress. Such a block is expected + // to be moved to a nested destination in the next operation. var block = Blockly.Xml.domToBlock(xmlChild, workspace); var blockX = parseInt(xmlChild.getAttribute('x'), 10); var blockY = parseInt(xmlChild.getAttribute('y'), 10);