Merge pull request #881 from rachel-fenichel/bugfix/events_rendered

Don't try to get block position in a headless workspace
This commit is contained in:
Rachel Fenichel
2017-01-27 13:06:35 -08:00
committed by GitHub

View File

@@ -354,7 +354,12 @@ Blockly.Events.Create = function(block) {
return; // Blank event to be populated by fromJson.
}
Blockly.Events.Create.superClass_.constructor.call(this, block);
this.xml = Blockly.Xml.blockToDomWithXY(block);
if (block.workspace.rendered) {
this.xml = Blockly.Xml.blockToDomWithXY(block);
} else {
this.xml = Blockly.Xml.blockToDom(block);
}
this.ids = Blockly.Events.getDescendantIds_(block);
};
goog.inherits(Blockly.Events.Create, Blockly.Events.Abstract);
@@ -423,7 +428,12 @@ Blockly.Events.Delete = function(block) {
throw 'Connected blocks cannot be deleted.';
}
Blockly.Events.Delete.superClass_.constructor.call(this, block);
this.oldXml = Blockly.Xml.blockToDomWithXY(block);
if (block.workspace.rendered) {
this.oldXml = Blockly.Xml.blockToDomWithXY(block);
} else {
this.oldXml = Blockly.Xml.blockToDom(block);
}
this.ids = Blockly.Events.getDescendantIds_(block);
};
goog.inherits(Blockly.Events.Delete, Blockly.Events.Abstract);