Fix error when undoing a shadow block replacement. Issue #415.

This commit is contained in:
Neil Fraser
2016-06-10 18:19:25 -07:00
parent 44f30cb997
commit 8c94a16bc6

View File

@@ -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);