mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Merge pull request #1135 from marisaleung/develop_deserialization_variables_at_top
Deserialization variables at top.
This commit is contained in:
11
core/xml.js
11
core/xml.js
@@ -332,6 +332,7 @@ Blockly.Xml.domToWorkspace = function(xml, workspace) {
|
||||
if (workspace.setResizesEnabled) {
|
||||
workspace.setResizesEnabled(false);
|
||||
}
|
||||
var variablesFirst = true;
|
||||
for (var i = 0; i < childCount; i++) {
|
||||
var xmlChild = xml.childNodes[i];
|
||||
var name = xmlChild.nodeName.toLowerCase();
|
||||
@@ -347,16 +348,20 @@ Blockly.Xml.domToWorkspace = function(xml, workspace) {
|
||||
if (!isNaN(blockX) && !isNaN(blockY)) {
|
||||
block.moveBy(workspace.RTL ? width - blockX : blockX, blockY);
|
||||
}
|
||||
variablesFirst = false;
|
||||
} else if (name == 'shadow') {
|
||||
goog.asserts.fail('Shadow block cannot be a top-level block.');
|
||||
variablesFirst = false;
|
||||
} else if (name == 'variables') {
|
||||
if (i == 1) {
|
||||
if (variablesFirst) {
|
||||
Blockly.Xml.domToVariables(xmlChild, workspace);
|
||||
}
|
||||
else {
|
||||
throw Error('\'variables\' tag must be the first element in the' +
|
||||
'workspace XML, but it was found in another location.');
|
||||
throw Error('\'variables\' tag must exist once before block and ' +
|
||||
'shadow tag elements in the workspace XML, but it was found in ' +
|
||||
'another location.');
|
||||
}
|
||||
variablesFirst = false;
|
||||
}
|
||||
}
|
||||
if (!existingGroup) {
|
||||
|
||||
Reference in New Issue
Block a user