Commit ca9ee114 authored by Neil Fraser's avatar Neil Fraser

Remove 'id' from XML unless realtime is enabled.

parent 8aa8bbb5
...@@ -62,7 +62,10 @@ Blockly.Xml.workspaceToDom = function(workspace) { ...@@ -62,7 +62,10 @@ Blockly.Xml.workspaceToDom = function(workspace) {
Blockly.Xml.blockToDom_ = function(block) { Blockly.Xml.blockToDom_ = function(block) {
var element = goog.dom.createDom('block'); var element = goog.dom.createDom('block');
element.setAttribute('type', block.type); element.setAttribute('type', block.type);
element.setAttribute('id', block.id); if (Blockly.Realtime.isEnabled()) {
// Only used by realtime.
element.setAttribute('id', block.id);
}
if (block.mutationToDom) { if (block.mutationToDom) {
// Custom data for an advanced block. // Custom data for an advanced block.
var mutation = block.mutationToDom(); var mutation = block.mutationToDom();
...@@ -297,6 +300,7 @@ Blockly.Xml.domToBlockHeadless_ = ...@@ -297,6 +300,7 @@ Blockly.Xml.domToBlockHeadless_ =
} }
var id = xmlBlock.getAttribute('id'); var id = xmlBlock.getAttribute('id');
if (opt_reuseBlock && id) { if (opt_reuseBlock && id) {
// Only used by realtime.
block = Blockly.Block.getById(id, workspace); block = Blockly.Block.getById(id, workspace);
// TODO: The following is for debugging. It should never actually happen. // TODO: The following is for debugging. It should never actually happen.
if (!block) { if (!block) {
...@@ -441,7 +445,7 @@ Blockly.Xml.domToBlockHeadless_ = ...@@ -441,7 +445,7 @@ Blockly.Xml.domToBlockHeadless_ =
} }
// Give the block a chance to clean up any initial inputs. // Give the block a chance to clean up any initial inputs.
if (block.validate) { if (block.validate) {
block.validate.call(block); block.validate();
} }
return block; return block;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment