From ca9ee114bcd908961c9de1c2d97829163ee4fdf8 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Fri, 28 Aug 2015 09:53:03 +0100 Subject: [PATCH] Remove 'id' from XML unless realtime is enabled. --- core/xml.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/xml.js b/core/xml.js index 730541e79..5d090fbea 100644 --- a/core/xml.js +++ b/core/xml.js @@ -62,7 +62,10 @@ Blockly.Xml.workspaceToDom = function(workspace) { Blockly.Xml.blockToDom_ = function(block) { var element = goog.dom.createDom('block'); 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) { // Custom data for an advanced block. var mutation = block.mutationToDom(); @@ -297,6 +300,7 @@ Blockly.Xml.domToBlockHeadless_ = } var id = xmlBlock.getAttribute('id'); if (opt_reuseBlock && id) { + // Only used by realtime. block = Blockly.Block.getById(id, workspace); // TODO: The following is for debugging. It should never actually happen. if (!block) { @@ -441,7 +445,7 @@ Blockly.Xml.domToBlockHeadless_ = } // Give the block a chance to clean up any initial inputs. if (block.validate) { - block.validate.call(block); + block.validate(); } return block; };