Fix unit tests

This commit is contained in:
Neil Fraser
2019-07-02 15:59:25 -07:00
committed by Neil Fraser
parent 20d4a27f0a
commit 52b6ce18a5
68 changed files with 186 additions and 186 deletions

View File

@@ -146,7 +146,7 @@ Blockly.Blocks['lists_create_with'] = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('items', this.itemCount_);
return container;
},
@@ -414,7 +414,7 @@ Blockly.Blocks['lists_getIndex'] = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
var isStatement = !this.outputConnection;
container.setAttribute('statement', isStatement);
var isAt = this.getInput('AT').type == Blockly.INPUT_VALUE;
@@ -578,7 +578,7 @@ Blockly.Blocks['lists_setIndex'] = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
var isAt = this.getInput('AT').type == Blockly.INPUT_VALUE;
container.setAttribute('at', isAt);
return container;
@@ -676,7 +676,7 @@ Blockly.Blocks['lists_getSublist'] = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
var isAt1 = this.getInput('AT1').type == Blockly.INPUT_VALUE;
container.setAttribute('at1', isAt1);
var isAt2 = this.getInput('AT2').type == Blockly.INPUT_VALUE;
@@ -856,7 +856,7 @@ Blockly.Blocks['lists_split'] = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('mode', this.getFieldValue('MODE'));
return container;
},

View File

@@ -320,7 +320,7 @@ Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN = {
if (!this.elseifCount_ && !this.elseCount_) {
return null;
}
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
if (this.elseifCount_) {
container.setAttribute('elseif', this.elseifCount_);
}

View File

@@ -268,7 +268,7 @@ Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN = {
option.text =
Blockly.Msg['VARIABLES_SET_CREATE_GET'].replace('%1', varName);
var xmlField = Blockly.Variables.generateVariableFieldDom(variable);
var xmlBlock = document.createElement('block');
var xmlBlock = Blockly.utils.xml.createElement('block');
xmlBlock.setAttribute('type', 'variables_get');
xmlBlock.appendChild(xmlField);
option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);

View File

@@ -460,7 +460,7 @@ Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
var divisorInput = (this.getFieldValue('PROPERTY') == 'DIVISIBLE_BY');
container.setAttribute('divisor_input', divisorInput);
return container;
@@ -545,7 +545,7 @@ Blockly.Constants.Math.LIST_MODES_MUTATOR_MIXIN = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('op', this.getFieldValue('OP'));
return container;
},

View File

@@ -108,12 +108,12 @@ Blockly.Blocks['procedures_defnoreturn'] = {
* @this Blockly.Block
*/
mutationToDom: function(opt_paramIds) {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
if (opt_paramIds) {
container.setAttribute('name', this.getFieldValue('NAME'));
}
for (var i = 0; i < this.argumentVarModels_.length; i++) {
var parameter = document.createElement('arg');
var parameter = Blockly.utils.xml.createElement('arg');
var argModel = this.argumentVarModels_[i];
parameter.setAttribute('name', argModel.name);
parameter.setAttribute('varid', argModel.getId());
@@ -354,14 +354,14 @@ Blockly.Blocks['procedures_defnoreturn'] = {
var option = {enabled: true};
var name = this.getFieldValue('NAME');
option.text = Blockly.Msg['PROCEDURES_CREATE_DO'].replace('%1', name);
var xmlMutation = document.createElement('mutation');
var xmlMutation = Blockly.utils.xml.createElement('mutation');
xmlMutation.setAttribute('name', name);
for (var i = 0; i < this.arguments_.length; i++) {
var xmlArg = document.createElement('arg');
var xmlArg = Blockly.utils.xml.createElement('arg');
xmlArg.setAttribute('name', this.arguments_[i]);
xmlMutation.appendChild(xmlArg);
}
var xmlBlock = document.createElement('block');
var xmlBlock = Blockly.utils.xml.createElement('block');
xmlBlock.setAttribute('type', this.callType_);
xmlBlock.appendChild(xmlMutation);
option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
@@ -376,7 +376,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
.replace('%1', argVar.name);
var argXmlField = Blockly.Variables.generateVariableFieldDom(argVar);
var argXmlBlock = document.createElement('block');
var argXmlBlock = Blockly.utils.xml.createElement('block');
argXmlBlock.setAttribute('type', 'variables_get');
argXmlBlock.appendChild(argXmlField);
argOption.callback =
@@ -814,10 +814,10 @@ Blockly.Blocks['procedures_callnoreturn'] = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('name', this.getProcedureCall());
for (var i = 0; i < this.arguments_.length; i++) {
var parameter = document.createElement('arg');
var parameter = Blockly.utils.xml.createElement('arg');
parameter.setAttribute('name', this.arguments_[i]);
container.appendChild(parameter);
}
@@ -880,7 +880,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
Blockly.Events.setGroup(event.group);
/**
* Create matching definition block.
* <xml>
* <xml xmlns="https://developers.google.com/blockly/xml">
* <block type="procedures_defreturn" x="10" y="20">
* <mutation name="test">
* <arg name="x"></arg>
@@ -889,8 +889,8 @@ Blockly.Blocks['procedures_callnoreturn'] = {
* </block>
* </xml>
*/
var xml = document.createElement('xml');
var block = document.createElement('block');
var xml = Blockly.utils.xml.createElement('xml');
var block = Blockly.utils.xml.createElement('block');
block.setAttribute('type', this.defType_);
var xy = this.getRelativeToSurfaceXY();
var x = xy.x + Blockly.SNAP_RADIUS * (this.RTL ? -1 : 1);
@@ -899,9 +899,10 @@ Blockly.Blocks['procedures_callnoreturn'] = {
block.setAttribute('y', y);
var mutation = this.mutationToDom();
block.appendChild(mutation);
var field = document.createElement('field');
var field = Blockly.utils.xml.createElement('field');
field.setAttribute('name', 'NAME');
field.appendChild(document.createTextNode(this.getProcedureCall()));
field.appendChild(Blockly.utils.xml.createTextNode(
this.getProcedureCall()));
block.appendChild(field);
xml.appendChild(block);
Blockly.Xml.domToWorkspace(xml, this.workspace);
@@ -1026,7 +1027,7 @@ Blockly.Blocks['procedures_ifreturn'] = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('value', Number(this.hasReturnValue_));
return container;
},

View File

@@ -243,7 +243,7 @@ Blockly.Blocks['text_getSubstring'] = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
var isAt1 = this.getInput('AT1').type == Blockly.INPUT_VALUE;
container.setAttribute('at1', isAt1);
var isAt2 = this.getInput('AT2').type == Blockly.INPUT_VALUE;
@@ -423,7 +423,7 @@ Blockly.Blocks['text_prompt_ext'] = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('type', this.getFieldValue('TYPE'));
return container;
},
@@ -660,7 +660,7 @@ Blockly.Constants.Text.TEXT_JOIN_MUTATOR_MIXIN = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('items', this.itemCount_);
return container;
},
@@ -810,7 +810,7 @@ Blockly.Constants.Text.TEXT_CHARAT_MUTATOR_MIXIN = {
* @this Blockly.Block
*/
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('at', !!this.isAt_);
return container;
},

View File

@@ -113,10 +113,10 @@ Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = {
var option = {enabled: this.workspace.remainingCapacity() > 0};
var name = this.getField('VAR').getText();
option.text = contextMenuMsg.replace('%1', name);
var xmlField = document.createElement('field');
var xmlField = Blockly.utils.xml.createElement('field');
xmlField.setAttribute('name', 'VAR');
xmlField.appendChild(document.createTextNode(name));
var xmlBlock = document.createElement('block');
xmlField.appendChild(Blockly.utils.xml.createTextNode(name));
var xmlBlock = Blockly.utils.xml.createElement('block');
xmlBlock.setAttribute('type', opposite_type);
xmlBlock.appendChild(xmlField);
option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);

View File

@@ -114,11 +114,11 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
var option = {enabled: this.workspace.remainingCapacity() > 0};
var name = this.getField('VAR').getText();
option.text = contextMenuMsg.replace('%1', name);
var xmlField = document.createElement('field');
var xmlField = Blockly.utils.xml.createElement('field');
xmlField.setAttribute('name', 'VAR');
xmlField.setAttribute('variabletype', varType);
xmlField.appendChild(document.createTextNode(name));
var xmlBlock = document.createElement('block');
xmlField.appendChild(Blockly.utils.xml.createTextNode(name));
var xmlBlock = Blockly.utils.xml.createElement('block');
xmlBlock.setAttribute('type', opposite_type);
xmlBlock.appendChild(xmlField);
option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);

View File

@@ -142,7 +142,7 @@ Blockly.FieldVariable.prototype.fromXml = function(fieldElement) {
};
/**
* Serialize this field to Xml.
* Serialize this field to XML.
* @param {!Element} fieldElement The element to populate with info about the
* field's state.
* @return {!Element} The element containing info about the field's state.
@@ -151,9 +151,9 @@ Blockly.FieldVariable.prototype.toXml = function(fieldElement) {
// Make sure the variable is initialized.
this.initModel();
fieldElement.setAttribute('id', this.variable_.getId());
fieldElement.id = this.variable_.getId();
fieldElement.textContent = this.variable_.name;
fieldElement.setAttribute('variableType', this.variable_.type);
fieldElement.setAttribute('variabletype', this.variable_.type);
return fieldElement;
};

View File

@@ -280,7 +280,7 @@ Blockly.WorkspaceComment.prototype.toXmlWithXY = function(opt_noId) {
Blockly.WorkspaceComment.prototype.toXml = function(opt_noId) {
var commentElement = Blockly.utils.xml.createElement('comment');
if (!opt_noId) {
commentElement.setAttribute('id', this.id);
commentElement.id = this.id;
}
commentElement.textContent = this.getContent();
return commentElement;

View File

@@ -207,7 +207,7 @@ Blockly.Events.CommentCreate.prototype.toJson = function() {
*/
Blockly.Events.CommentCreate.prototype.fromJson = function(json) {
Blockly.Events.CommentCreate.superClass_.fromJson.call(this, json);
this.xml = Blockly.Xml.textToDom('<xml>' + json['xml'] + '</xml>').firstChild;
this.xml = Blockly.Xml.textToDom(json['xml']);
};
/**

View File

@@ -75,7 +75,7 @@ Blockly.Xml.variablesToDom = function(variableList) {
var element = Blockly.utils.xml.createElement('variable');
element.appendChild(Blockly.utils.xml.createTextNode(variable.name));
element.setAttribute('type', variable.type);
element.setAttribute('id', variable.getId());
element.id = variable.getId();
variables.appendChild(element);
}
return variables;
@@ -146,7 +146,7 @@ Blockly.Xml.blockToDom = function(block, opt_noId) {
Blockly.utils.xml.createElement(block.isShadow() ? 'shadow' : 'block');
element.setAttribute('type', block.type);
if (!opt_noId) {
element.setAttribute('id', block.id);
element.id = block.id;
}
if (block.mutationToDom) {
// Custom data for an advanced block.

View File

@@ -70,7 +70,7 @@
});
</script>
<xml id="blockly-toolbox-xml" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="blockly-toolbox-xml" style="display: none">
<category name="Logic" colour="210">
<block type="controls_if"></block>
<block type="logic_compare"></block>

View File

@@ -150,7 +150,7 @@ AppController.prototype.exportBlockLibraryToFile = function() {
*/
AppController.prototype.formatBlockLibraryForExport_ = function(blockXmlMap) {
// Create DOM for XML.
var xmlDom = document.createElementNS('http://www.w3.org/1999/xhtml', 'xml');
var xmlDom = Blockly.utils.xml.createElemen('xml');
// Append each block node to XML DOM.
for (var blockType in blockXmlMap) {
@@ -185,8 +185,7 @@ AppController.prototype.formatBlockLibraryForImport_ = function(xmlText) {
// Add outer XML tag to the block for proper injection in to the
// main workspace.
// Create DOM for XML.
var editorWorkspaceXml =
document.createElementNS('http://www.w3.org/1999/xhtml', 'xml');
var editorWorkspaceXml = Blockly.utils.xml.createElement('xml');
editorWorkspaceXml.appendChild(blockNode);
xmlText = Blockly.Xml.domToText(editorWorkspaceXml);

View File

@@ -39,10 +39,8 @@ var BlockDefinitionExtractor = BlockDefinitionExtractor || Object.create(null);
* workspace.
*/
BlockDefinitionExtractor.buildBlockFactoryWorkspace = function(block) {
var workspaceXml = document.createElement('xml');
workspaceXml.append(
BlockDefinitionExtractor.factoryBase_(block, block.type));
var workspaceXml = Blockly.utils.xml.createElement('xml');
workspaceXml.append(BlockDefinitionExtractor.factoryBase_(block, block.type));
return workspaceXml;
};
@@ -58,7 +56,7 @@ BlockDefinitionExtractor.buildBlockFactoryWorkspace = function(block) {
*/
BlockDefinitionExtractor.newDomElement_ = function(name, opt_attrs, opt_text) {
// Avoid createDom(..)'s attributes argument for being too HTML specific.
var elem = document.createElement(name);
var elem = Blockly.utils.xml.createElement(name);
if (opt_attrs) {
for (var key in opt_attrs) {
elem.setAttribute(key, opt_attrs[key]);

View File

@@ -136,7 +136,7 @@ BlockLibraryController.prototype.saveToBlockLibrary = function() {
}
// Create block XML.
var xmlElement = document.createElement('xml');
var xmlElement = Blockly.utils.xml.createElement('xml');
var block = FactoryUtils.getRootBlock(BlockFactory.mainWorkspace);
xmlElement.appendChild(Blockly.Xml.blockToDomWithXY(block));

View File

@@ -67,7 +67,7 @@ Blockly.Blocks['factory_base'] = {
'https://developers.google.com/blockly/guides/create-custom-blocks/block-factory');
},
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('connections', this.getFieldValue('CONNECTIONS'));
return container;
},
@@ -356,7 +356,7 @@ Blockly.Blocks['field_dropdown'] = {
},
mutationToDom: function(workspace) {
// Create XML to represent menu options.
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('options', JSON.stringify(this.optionList_));
return container;
},
@@ -648,7 +648,7 @@ Blockly.Blocks['type_group'] = {
},
mutationToDom: function(workspace) {
// Create XML to represent a group of types.
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('types', this.typeCount_);
return container;
},
@@ -867,7 +867,7 @@ Blockly.Blocks['colour_hue'] = {
}
},
mutationToDom: function(workspace) {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('colour', this.getColour());
return container;
},

View File

@@ -78,8 +78,9 @@ BlockFactory.updateBlocksFlagDelayed = false;
* The starting XML for the Block Factory main workspace. Contains the
* unmovable, undeletable factory_base block.
*/
BlockFactory.STARTER_BLOCK_XML_TEXT = '<xml><block type="factory_base" ' +
'deletable="false" movable="false">' +
BlockFactory.STARTER_BLOCK_XML_TEXT =
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="factory_base" deletable="false" movable="false">' +
'<value name="TOOLTIP">' +
'<block type="text" deletable="false" movable="false">' +
'<field name="TEXT"></field></block></value>' +

View File

@@ -780,7 +780,7 @@ FactoryUtils.getBlockTypeFromJsDefinition = function(blockDef) {
*/
FactoryUtils.generateCategoryXml = function(blocks, categoryName) {
// Create category DOM element.
var categoryElement = document.createElement('category');
var categoryElement = Blockly.utils.xml.createElement('category');
categoryElement.setAttribute('name', categoryName);
// For each block, add block element to category.

View File

@@ -407,7 +407,7 @@
<div id="modalShadow"></div>
<xml id="blockfactory_toolbox" class="toolbox">
<xml xmlns="https://developers.google.com/blockly/xml" id="blockfactory_toolbox" class="toolbox">
<category name="Input">
<block type="input_value">
<value name="TYPE">
@@ -460,7 +460,7 @@
</category>
</xml>
<xml id="workspacefactory_toolbox" class="toolbox">
<xml xmlns="https://developers.google.com/blockly/xml" id="workspacefactory_toolbox" class="toolbox">
<category name="Logic" colour="210">
<block type="controls_if"></block>
<block type="logic_compare"></block>

View File

@@ -43,7 +43,7 @@ StandardCategories.categoryMap['logic'] =
new ListElement(ListElement.TYPE_CATEGORY, 'Logic');
StandardCategories.categoryMap['logic'].xml =
Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="controls_if"></block>' +
'<block type="logic_compare"></block>' +
'<block type="logic_operation"></block>' +
@@ -58,7 +58,7 @@ StandardCategories.categoryMap['loops'] =
new ListElement(ListElement.TYPE_CATEGORY, 'Loops');
StandardCategories.categoryMap['loops'].xml =
Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="controls_repeat_ext">' +
'<value name="TIMES">' +
'<shadow type="math_number">' +
@@ -93,7 +93,7 @@ StandardCategories.categoryMap['math'] =
new ListElement(ListElement.TYPE_CATEGORY, 'Math');
StandardCategories.categoryMap['math'].xml =
Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="math_number"></block>' +
'<block type="math_arithmetic">' +
'<value name="A">' +
@@ -186,7 +186,7 @@ StandardCategories.categoryMap['text'] =
new ListElement(ListElement.TYPE_CATEGORY, 'Text');
StandardCategories.categoryMap['text'].xml =
Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="text"></block>' +
'<block type="text_join"></block>' +
'<block type="text_append">' +
@@ -269,7 +269,7 @@ StandardCategories.categoryMap['lists'] =
new ListElement(ListElement.TYPE_CATEGORY, 'Lists');
StandardCategories.categoryMap['lists'].xml =
Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="lists_create_with">' +
'<mutation items="0"></mutation>' +
'</block>' +
@@ -326,7 +326,7 @@ StandardCategories.categoryMap['colour'] =
new ListElement(ListElement.TYPE_CATEGORY, 'Colour');
StandardCategories.categoryMap['colour'].xml =
Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="colour_picker"></block>' +
'<block type="colour_random"></block>' +
'<block type="colour_rgb">' +

View File

@@ -64,7 +64,7 @@ WorkspaceFactoryController = function(toolboxName, toolboxDiv, previewDiv) {
colour: '#ccc',
snap: true},
media: '../../media/',
toolbox: '<xml></xml>',
toolbox: '<xml xmlns="https://developers.google.com/blockly/xml"></xml>',
zoom:
{controls: true,
wheel: true}
@@ -328,17 +328,17 @@ WorkspaceFactoryController.prototype.exportXmlFile = function(exportMode) {
// Generate XML.
if (exportMode == WorkspaceFactoryController.MODE_TOOLBOX) {
// Export the toolbox XML.
var configXml = Blockly.Xml.domToPrettyText
(this.generator.generateToolboxXml());
var configXml = Blockly.Xml.domToPrettyText(
this.generator.generateToolboxXml());
this.hasUnsavedToolboxChanges = false;
} else if (exportMode == WorkspaceFactoryController.MODE_PRELOAD) {
// Export the pre-loaded block XML.
var configXml = Blockly.Xml.domToPrettyText
(this.generator.generateWorkspaceXml());
var configXml = Blockly.Xml.domToPrettyText(
this.generator.generateWorkspaceXml());
this.hasUnsavedPreloadChanges = false;
} else {
// Unknown mode. Throw error.
var msg = "Unknown export mode: " + exportMode;
var msg = 'Unknown export mode: ' + exportMode;
BlocklyDevTools.Analytics.onError(msg);
throw new Error(msg);
}
@@ -757,7 +757,7 @@ WorkspaceFactoryController.prototype.importFile = function(file, importMode) {
BlocklyDevTools.Analytics.onImport('WorkspaceContents.xml');
} else {
// Throw error if invalid mode.
throw new Error("Unknown import mode: " + importMode);
throw new Error('Unknown import mode: ' + importMode);
}
} catch(e) {
var msg = 'Cannot load XML from file.';
@@ -904,7 +904,7 @@ WorkspaceFactoryController.prototype.clearAll = function() {
var hasCategories = this.model.hasElements();
this.model.clearToolboxList();
this.view.clearToolboxTabs();
this.model.savePreloadXml(Blockly.Xml.textToDom('<xml></xml>'));
this.model.savePreloadXml(Blockly.utils.xml.createElement('xml'));
this.view.addEmptyCategoryMessage();
this.view.updateState(-1, null);
this.toolboxWorkspace.clear();
@@ -1099,8 +1099,8 @@ WorkspaceFactoryController.prototype.setStandardOptionsAndUpdate = function() {
WorkspaceFactoryController.prototype.generateNewOptions = function() {
this.model.setOptions(this.readOptions_());
this.reinjectPreview(Blockly.Options.parseToolboxTree
(this.generator.generateToolboxXml()));
this.reinjectPreview(Blockly.Options.parseToolboxTree(
this.generator.generateToolboxXml()));
};
/**
@@ -1274,7 +1274,7 @@ WorkspaceFactoryController.prototype.setBlockLibCategory =
// Set category ID so that it can be easily replaced, and set a standard,
// arbitrary block library color.
categoryXml.setAttribute('id', 'blockLibCategory');
categoryXml.id = 'blockLibCategory';
categoryXml.setAttribute('colour', 260);
// Update the toolbox and toolboxWorkspace.
@@ -1317,8 +1317,8 @@ WorkspaceFactoryController.prototype.warnForUndefinedBlocks_ = function() {
var blocks = this.toolboxWorkspace.getAllBlocks(false);
for (var i = 0, block; block = blocks[i]; i++) {
if (!this.isDefinedBlock(block)) {
block.setWarningText(block.type + ' is not defined (it is not a standard '
+ 'block, \nin your block library, or an imported block)');
block.setWarningText(block.type + ' is not defined (it is not a ' +
'standard block,\nin your block library, or an imported block)');
}
}
};

View File

@@ -59,9 +59,9 @@ WorkspaceFactoryGenerator = function(model) {
*/
WorkspaceFactoryGenerator.prototype.generateToolboxXml = function() {
// Create DOM for XML.
var xmlDom = document.createElement('xml');
var xmlDom = Blockly.utils.xml.createElement('xml');
xmlDom.id = 'toolbox';
xmlDom.style.display = 'none';
xmlDom.setAttribute('style', 'display: none');
if (!this.model.hasElements()) {
// Toolbox has no categories. Use XML directly from workspace.
@@ -85,10 +85,10 @@ WorkspaceFactoryGenerator.prototype.generateToolboxXml = function() {
var element = toolboxList[i];
if (element.type == ListElement.TYPE_SEPARATOR) {
// If the next element is a separator.
var nextElement = document.createElement('sep');
var nextElement = Blockly.utils.xml.createElement('sep');
} else if (element.type == ListElement.TYPE_CATEGORY) {
// If the next element is a category.
var nextElement = document.createElement('category');
var nextElement = Blockly.utils.xml.createElement('category');
nextElement.setAttribute('name', element.name);
// Add a colour attribute if one exists.
if (element.color != null) {
@@ -125,10 +125,10 @@ WorkspaceFactoryGenerator.prototype.generateWorkspaceXml = function() {
this.setShadowBlocksInHiddenWorkspace_();
// Generate XML and set attributes.
var generatedXml = Blockly.Xml.workspaceToDom(this.hiddenWorkspace);
generatedXml.setAttribute('id', 'workspaceBlocks');
generatedXml.setAttribute('style', 'display:none');
return generatedXml;
var xmlDom = Blockly.Xml.workspaceToDom(this.hiddenWorkspace);
xmlDom.id = 'workspaceBlocks';
xmlDom.setAttribute('style', 'display: none');
return xmlDom;
};
/**

View File

@@ -50,7 +50,7 @@ WorkspaceFactoryModel = function() {
// Boolean for if a Procedure category has been added.
this.hasProcedureCategory = false;
// XML to be pre-loaded to workspace. Empty on default;
this.preloadXml = Blockly.Xml.textToDom('<xml></xml>');
this.preloadXml = Blockly.utils.xml.createElement('xml');
// Options object to be configured for Blockly inject call.
this.options = new Object(null);
// Block Library block types.
@@ -288,7 +288,7 @@ WorkspaceFactoryModel.prototype.clearToolboxList = function() {
this.hasVariableCategory = false;
this.hasProcedureCategory = false;
this.shadowBlocks = [];
this.selected.xml = Blockly.Xml.textToDom('<xml></xml>');
this.selected.xml = Blockly.utils.xml.createElement('xml');
};
/**
@@ -488,7 +488,7 @@ WorkspaceFactoryModel.prototype.hasDefinedBlockTypes = function(blockTypes) {
ListElement = function(type, opt_name) {
this.type = type;
// XML DOM element to load the element.
this.xml = Blockly.Xml.textToDom('<xml></xml>');
this.xml = Blockly.utils.xml.createElement('xml');
// Name of category. Can be changed by user. Null if separator.
this.name = opt_name ? opt_name : null;
// Unique ID of element. Does not change.

View File

@@ -61,7 +61,7 @@ Blockly.Blocks['factory_base'] = {
'https://developers.google.com/blockly/guides/create-custom-blocks/block-factory');
},
mutationToDom: function() {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('connections', this.getFieldValue('CONNECTIONS'));
return container;
},
@@ -329,7 +329,7 @@ Blockly.Blocks['field_dropdown'] = {
},
mutationToDom: function(workspace) {
// Create XML to represent menu options.
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('options', this.optionCount_);
return container;
},
@@ -547,7 +547,7 @@ Blockly.Blocks['type_group'] = {
},
mutationToDom: function(workspace) {
// Create XML to represent a group of types.
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('types', this.typeCount_);
return container;
},
@@ -766,7 +766,7 @@ Blockly.Blocks['colour_hue'] = {
}
},
mutationToDom: function(workspace) {
var container = document.createElement('mutation');
var container = Blockly.utils.xml.createElement('mutation');
container.setAttribute('colour', this.getColour());
return container;
},

View File

@@ -829,7 +829,7 @@ function init() {
BlocklyStorage.retrieveXml(window.location.hash.substring(1),
mainWorkspace);
} else {
var xml = '<xml><block type="factory_base" deletable="false" movable="false"></block></xml>';
var xml = '<xml xmlns="https://developers.google.com/blockly/xml"><block type="factory_base" deletable="false" movable="false"></block></xml>';
Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(xml), mainWorkspace);
}
mainWorkspace.clearUndo();

View File

@@ -174,7 +174,7 @@
</td>
</tr>
</table>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Input">
<block type="input_value">
<value name="TYPE">

View File

@@ -73,7 +73,7 @@
<pre id="content_dart" class="content prettyprint lang-dart"></pre>
<textarea id="content_xml" class="content" wrap="off"></textarea>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="%{BKY_CATLOGIC}" colour="%{BKY_LOGIC_HUE}">
<block type="controls_if"></block>
<block type="logic_compare"></block>

View File

@@ -43,7 +43,7 @@
<div class="blockly-editor">
<div id="blockly-div" style="height: 480px; width: 400px;"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Loops" colour="120">
<block type="controls_repeat_ext">
<value name="TIMES">

View File

@@ -32,7 +32,7 @@
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Inputs" colour="%{BKY_MATH_HUE}">
<block type="math_number" gap="32">
<field name="NUM">123</field>

View File

@@ -27,7 +27,7 @@
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>

View File

@@ -34,7 +34,7 @@
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Logic" colour="%{BKY_LOGIC_HUE}">
<block type="controls_if"></block>
<block type="logic_compare"></block>
@@ -66,7 +66,7 @@
</category>
</xml>
<xml id="startBlocks" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="startBlocks" style="display: none">
<block type="controls_if" inline="false" x="20" y="20">
<mutation else="1"></mutation>
<value name="IF0">

View File

@@ -57,7 +57,7 @@
...
</div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Math" colour="%{BKY_MATH_HUE}">
<block type="math_number">
<field name="NUM">123</field>
@@ -170,7 +170,7 @@
</category>
</xml>
<xml id="startBlocks" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="startBlocks" style="display: none">
<block type="graph_set_y" deletable="false" x="100" y="100">
<value name="VALUE">
<block type="math_arithmetic">

View File

@@ -36,7 +36,7 @@
<tr>
<td style="width:50%">
<textarea id="xml_input">
<xml>
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="controls_if" inline="false" x="20" y="20">
<mutation else="1"></mutation>
<value name="IF0">

View File

@@ -40,7 +40,7 @@
</textarea>
</div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Logic" colour="%{BKY_LOGIC_HUE}">
<block type="controls_if"></block>
<block type="logic_compare"></block>
@@ -82,7 +82,7 @@
</category>
</xml>
<xml id="startBlocks" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="startBlocks" style="display: none">
<block type="variables_set" id="set_n_initial" inline="true" x="20" y="20">
<field name="VAR">n</field>
<value name="VALUE">

View File

@@ -47,7 +47,7 @@
</textarea>
</div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Logic" colour="%{BKY_LOGIC_HUE}">
<block type="controls_if"></block>
<block type="logic_compare"></block>
@@ -89,7 +89,7 @@
</category>
</xml>
<xml id="startBlocks" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="startBlocks" style="display: none">
<block type="variables_set" id="set_n_initial" inline="true" x="20" y="20">
<field name="VAR">n</field>
<value name="VALUE">

View File

@@ -31,7 +31,7 @@
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Logic" colour="%{BKY_LOGIC_HUE}">
<block type="controls_if"></block>
<block type="logic_compare"></block>

View File

@@ -35,7 +35,7 @@
</tr>
</table>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>

View File

@@ -37,7 +37,7 @@
</tr>
</table>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>

View File

@@ -5,7 +5,7 @@ var BLOCKLY_TOOLBOX_XML = BLOCKLY_TOOLBOX_XML || Object.create(null);
BLOCKLY_TOOLBOX_XML['standard'] =
// From XML string/file, replace ^\s?(\s*)?(<.*>)$ with \+$1'$2'
// Tweak first and last line.
'<xml>'
'<xml xmlns="https://developers.google.com/blockly/xml">'
+ '<category name="Logic" colour="%{BKY_LOGIC_HUE}">'
+ '<block type="controls_if"></block>'
+ '<block type="logic_compare"></block>'

View File

@@ -269,7 +269,7 @@ Plane.init = function() {
toolbox: document.getElementById('toolbox')});
var defaultXml =
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="plane_set_seats" deletable="false" x="70" y="70">' +
' </block>' +
'</xml>';
@@ -396,7 +396,7 @@ Plane.redraw = function(newRows) {
while (newRows > rows1st) {
rows1st++;
var row = document.createElementNS('http://www.w3.org/2000/svg', 'use');
row.setAttribute('id', 'row1st' + rows1st);
row.id = 'row1st' + rows1st;
// Row of 4 seats.
row.setAttribute('x', (rows1st - 1) * 20);
row.setAttributeNS('http://www.w3.org/1999/xlink',
@@ -413,9 +413,8 @@ Plane.redraw = function(newRows) {
}
while (newRows > rows2nd) {
rows2nd++;
var row = document.createElementNS('http://www.w3.org/2000/svg',
'use');
row.setAttribute('id', 'row2nd' + rows2nd);
var row = document.createElementNS('http://www.w3.org/2000/svg', 'use');
row.id = 'row2nd' + rows2nd;
row.setAttribute('x', 400 - (rows2nd - 1) * 18);
row.setAttributeNS('http://www.w3.org/1999/xlink',
'xlink:href', '#row2nd');

View File

@@ -188,7 +188,7 @@
* Toolboxes for each level.
*/
{template .toolbox}
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<block type="math_number"></block>
<block type="math_arithmetic">
<value name="A">

View File

@@ -53,7 +53,7 @@
<div id="blocklyDiv" style="position: absolute"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>

View File

@@ -41,7 +41,7 @@
<div id="blocklyDiv"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="منطق" colour="%{BKY_LOGIC_HUE}">
<block type="controls_if"></block>
<block type="logic_compare"></block>
@@ -168,7 +168,7 @@
</category>
</xml>
<xml id="startBlocks" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="startBlocks" style="display: none">
<block type="controls_if" inline="false" x="50" y="50">
<value name="IF0">
<block type="logic_compare" inline="true">

View File

@@ -49,7 +49,7 @@
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Logic" colour="%{BKY_LOGIC_HUE}">
<block type="controls_if"></block>
<block type="logic_compare"></block>

View File

@@ -27,7 +27,7 @@
<div id="blocklyDiv" style="height: 600px; width: 800px;"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Logic" colour="%{BKY_LOGIC_HUE}">
<category name="If">
<block type="controls_if"></block>

View File

@@ -26,7 +26,7 @@
this page and see if Blockly works.</p>
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="procedures_defnoreturn" x="260" y="14">
<field name="NAME">test colour picker</field>
<comment pinned="false" h="80" w="160">Describe this function...</comment>

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<!-- Do not include <variables> here to test backward compatibility. -->
<block type="unittest_main" x="0" y="1">
<field name="SUITE_NAME">Functions</field>

View File

@@ -294,7 +294,7 @@ h1 {
<div id="blocklyDiv"></div>
<xml id="toolbox" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Unit test" colour="65">
<block type="unittest_main"></block>
<block type="unittest_assertequals">

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="unittest_main" x="13" y="13">
<field name="SUITE_NAME">Lists</field>
<statement name="DO">

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="unittest_main" x="-13" y="-13">
<field name="SUITE_NAME">Logic</field>
<statement name="DO">

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="unittest_main" x="33" y="140">
<field name="SUITE_NAME">Loops 1</field>
<statement name="DO">

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="unittest_main" x="66" y="-2">
<field name="SUITE_NAME">Loops 2</field>
<statement name="DO">

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="unittest_main" x="19" y="106">
<field name="SUITE_NAME">Loops 3</field>
<statement name="DO">

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="unittest_main" x="13" y="13">
<field name="SUITE_NAME">Math</field>
<statement name="DO">

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<block type="unittest_main" x="13" y="-63">
<field name="SUITE_NAME">Text</field>
<statement name="DO">

View File

@@ -1,4 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<xml xmlns="https://developers.google.com/blockly/xml">
<!-- Do not include <variables> here to test backward compatibility. -->
<block type="unittest_main" x="0" y="0">
<field name="SUITE_NAME">Variables</field>

View File

@@ -755,7 +755,7 @@ function test_events_newblock_newvar_xml() {
temporary_fireEvent.firedEvents_ = [];
try {
var dom = Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="field_variable_test_block" id="block1">' +
' <field name="VAR" id="id1" variabletype="">name1</field>' +
' </block>' +
@@ -811,4 +811,4 @@ function test_events_filter_nomerge_move() {
} finally {
eventTest_tearDownWithMockBlocks();
}
}
}

View File

@@ -24,7 +24,7 @@ goog.require('goog.testing.MockControl');
var mockControl_;
var workspace;
var XML_TEXT = ['<xml xmlns="http://www.w3.org/1999/xhtml">',
var XML_TEXT = ['<xml xmlns="https://developers.google.com/blockly/xml">',
' <block type="controls_repeat_ext" inline="true" x="21" y="23">',
' <value name="TIMES">',
' <block type="math_number">',
@@ -35,7 +35,7 @@ var XML_TEXT = ['<xml xmlns="http://www.w3.org/1999/xhtml">',
' <block type="variables_set" inline="true">',
' <field name="VAR">item</field>',
' <value name="VALUE">',
' <block type="lists_create_empty"></block>',
' <block type="lists_create_empty" />',
' </value>',
' <next>',
' <block type="text_print" inline="false">',
@@ -88,10 +88,10 @@ function xmlTest_tearDownWithMockBlocks() {
* @param {!string} text The expected text of the variable.
*/
function xmlTest_checkNonVariableField(fieldDom, name, text) {
assertEquals(text, fieldDom.textContent);
assertEquals(name, fieldDom.getAttribute('name'));
assertNull(fieldDom.getAttribute('id'));
assertNull(fieldDom.getAttribute('variabletype'));
assertEquals('textContent', text, fieldDom.textContent);
assertEquals('name', name, fieldDom.getAttribute('name'));
assertNull('id', fieldDom.getAttribute('id'));
assertNull('variabletype', fieldDom.getAttribute('variabletype'));
}
/**
@@ -103,10 +103,10 @@ function xmlTest_checkNonVariableField(fieldDom, name, text) {
* @param {!string} text The expected text of the variable.
*/
function xmlTest_checkVariableFieldDomValues(fieldDom, name, type, id, text) {
assertEquals(name, fieldDom.getAttribute('name'));
assertEquals(type, fieldDom.getAttribute('variabletype'));
assertEquals(id, fieldDom.getAttribute('id'));
assertEquals(text, fieldDom.textContent);
assertEquals('name', name, fieldDom.getAttribute('name'));
assertEquals('variabletype', type, fieldDom.getAttribute('variabletype'));
assertEquals('id', id, fieldDom.getAttribute('id'));
assertEquals('textContent', text, fieldDom.textContent);
}
/**
@@ -117,9 +117,9 @@ function xmlTest_checkVariableFieldDomValues(fieldDom, name, type, id, text) {
* @param {!string} text The expected text of the variable.
*/
function xmlTest_checkVariableDomValues(variableDom, type, id, text) {
assertEquals(type, variableDom.getAttribute('type'));
assertEquals(id, variableDom.getAttribute('id'));
assertEquals(text, variableDom.textContent);
assertEquals('type', type, variableDom.getAttribute('type'));
assertEquals('id', id, variableDom.getAttribute('id'));
assertEquals('textContent', text, variableDom.textContent);
}
function test_textToDom() {
@@ -141,7 +141,7 @@ function test_domToWorkspace_BackwardCompatibility() {
setUpMockMethod(mockControl_, Blockly.utils, 'genUid', null, ['1', '1']);
try {
var dom = Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="field_variable_test_block" id="block_id">' +
' <field name="VAR">name1</field>' +
' </block>' +
@@ -159,7 +159,7 @@ function test_domToWorkspace_VariablesAtTop() {
xmlTest_setUpWithMockBlocks();
try {
var dom = Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <variables>' +
' <variable type="type1" id="id1">name1</variable>' +
' <variable type="type2" id="id2">name2</variable>' +
@@ -184,7 +184,7 @@ function test_domToWorkspace_VariablesAtTop_DuplicateVariablesTag() {
xmlTest_setUpWithMockBlocks();
try {
var dom = Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <variables>' +
' </variables>' +
' <variables>' +
@@ -205,7 +205,7 @@ function test_domToWorkspace_VariablesAtTop_MissingType() {
workspace = new Blockly.Workspace();
try {
var dom = Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <variables>' +
' <variable id="id1">name1</variable>' +
' </variables>' +
@@ -228,7 +228,7 @@ function test_domToWorkspace_VariablesAtTop_MismatchBlockType() {
xmlTest_setUpWithMockBlocks();
try {
var dom = Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <variables>' +
' <variable type="type1" id="id1">name1</variable>' +
' </variables>' +
@@ -267,7 +267,7 @@ function test_appendDomToWorkspace() {
try {
var dom = Blockly.Xml.textToDom(
'<xml xmlns="http://www.w3.org/1999/xhtml">' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="test_block" inline="true" x="21" y="23">' +
' </block>' +
'</xml>');

View File

@@ -359,7 +359,7 @@ suite('Abstract Fields', function() {
},
};
var block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="tooltip"></block>' +
'</xml>'
).children[0], this.workspace);
@@ -377,7 +377,7 @@ suite('Abstract Fields', function() {
},
};
var block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="tooltip"></block>' +
'</xml>'
).children[0], this.workspace);
@@ -394,7 +394,7 @@ suite('Abstract Fields', function() {
},
};
var block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="tooltip"></block>' +
'</xml>'
).children[0], this.workspace);
@@ -417,7 +417,7 @@ suite('Abstract Fields', function() {
}
};
var block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="tooltip"></block>' +
'</xml>'
).children[0], this.workspace);
@@ -438,7 +438,7 @@ suite('Abstract Fields', function() {
}
};
var block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="tooltip"></block>' +
'</xml>'
).children[0], this.workspace);
@@ -456,7 +456,7 @@ suite('Abstract Fields', function() {
},
};
var block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="tooltip"></block>' +
'</xml>'
).children[0], this.workspace);
@@ -473,7 +473,7 @@ suite('Abstract Fields', function() {
},
};
var block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="tooltip"></block>' +
'</xml>'
).children[0], this.workspace);

View File

@@ -45,7 +45,7 @@
<script src="utils_test.js"></script>
<div id="blocklyDiv"></div>
<xml id="toolbox-connections" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox-connections" style="display: none">
<block type="stack_block"></block>
<block type="row_block"></block>
</xml>

View File

@@ -31,7 +31,9 @@ suite("Trashcan", function() {
}
};
function sendDeleteEvent(xmlString) {
var xml = Blockly.Xml.textToDom('<xml>' + xmlString + '</xml>');
var xml = Blockly.Xml.textToDom(
'<xml xmlns="https://developers.google.com/blockly/xml">' +
xmlString + '</xml>');
xml = xml.children[0];
var event = {
type: Blockly.Events.BLOCK_DELETE,
@@ -63,7 +65,7 @@ suite("Trashcan", function() {
});
test("Non-Delete w/ oldXml", function() {
var xml = Blockly.Xml.textToDom(
'<xml>' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="dummy_type"/>' +
'</xml>'
);

View File

@@ -142,7 +142,7 @@ h1 {
</tr>
</table>
<xml id="toolbox-simple" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox-simple" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<!-- <block type="control_repeat"></block> -->
@@ -161,7 +161,7 @@ h1 {
<block type="logic_ternary"></block>
</xml>
<xml id="toolbox-categories" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox-categories" style="display: none">
<category name="Logic" colour="%{BKY_LOGIC_HUE}">
<block type="controls_if"></block>
<block type="logic_compare"></block>

View File

@@ -148,7 +148,7 @@ function addToolboxButtonCallbacks() {
var workspace = button.getTargetWorkspace();
var blocks = button.workspace_.getTopBlocks();
for(var i = 0, block; block = blocks[i]; i++) {
var xml = Blockly.Xml.textToDom('<xml></xml>');
var xml = Blockly.utils.xml.createElement('xml');
xml.appendChild(Blockly.Xml.blockToDom(block));
Blockly.Xml.appendDomToWorkspace(xml, workspace);
}
@@ -355,7 +355,7 @@ function spaghetti(n) {
xml = xml.replace(/(<(statement|next)( name="DO0")?>)<\//g,
'$1' + spaghettiXml + '</');
}
xml = '<xml xmlns="http://www.w3.org/1999/xhtml">' + xml + '</xml>';
xml = '<xml xmlns="https://developers.google.com/blockly/xml">' + xml + '</xml>';
var dom = Blockly.Xml.textToDom(xml);
console.time('Spaghetti domToWorkspace');
Blockly.Xml.domToWorkspace(dom, workspace);
@@ -488,7 +488,7 @@ h1 {
<!-- toolbox-simple is an always-open flyout with no category menu.
Always-open flyouts are a good idea if you have a small number of blocks. -->
<xml id="toolbox-simple" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox-simple" style="display: none">
<block type="controls_ifelse"></block>
<block type="logic_compare"></block>
<!-- <block type="control_repeat"></block> -->
@@ -517,7 +517,7 @@ h1 {
<!-- toolbox-categories has a category menu and an auto-closing flyout. The
Variables category uses untyped variable blocks.
See https://developers.google.com/blockly/guides/create-custom-blocks/variables#untyped_variable_blocks for more information. -->
<xml id="toolbox-categories" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox-categories" style="display: none">
<category name="Logic" categorystyle="logic_category">
<block type="controls_if"></block>
<block type="logic_compare"></block>
@@ -858,7 +858,7 @@ h1 {
<!-- toolbox-categories-typed-variables has a category menu and an
auto-closing flyout. The Variables category uses typed variable blocks.
See https://developers.google.com/blockly/guides/create-custom-blocks/variables#typed_variable_blocks for more information. -->
<xml id="toolbox-categories-typed-variables" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox-categories-typed-variables" style="display: none">
<category name="Logic" categorystyle="logic_category">
<block type="controls_if"></block>
<block type="logic_compare"></block>
@@ -1198,9 +1198,9 @@ h1 {
<!-- toolbox-test-blocks has a category menu and an auto-closing flyout.
The blocks in this toolbox reflect block configurations not used by
the standard predefined blocks, and so test alernative block rendering
the standard predefined blocks, and so test alternative block rendering
code paths. -->
<xml id="toolbox-test-blocks" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox-test-blocks" style="display: none">
<category name="Basic">
<block type="test_basic_empty"></block>
<block type="test_basic_empty_with_mutator"></block>

View File

@@ -57,7 +57,7 @@ h1 {
<!-- TODO (#1960): Uncomment once comment deletion is fixed. -->
<!--<script src="event_svg_test.js"></script>-->
<xml id="toolbox-simple" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox-simple" style="display: none">
<block type="controls_ifelse"></block>
<block type="logic_compare"></block>
<!-- <block type="control_repeat"></block> -->
@@ -76,7 +76,7 @@ h1 {
<block type="logic_ternary"></block>
</xml>
<xml id="toolbox-categories" style="display: none">
<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox-categories" style="display: none">
<category name="Logic" colour="210">
<block type="controls_if"></block>
<block type="logic_compare"></block>

View File

@@ -45,7 +45,7 @@ function test_procedureReturnSetDisabledUpdatesCallers() {
procedureSvgTest_setup();
try {
var dom = Blockly.Xml.textToDom(
'<xml xmlns="http://www.w3.org/1999/xhtml">' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="procedures_defreturn" id="bar-def">' +
'<field name="NAME">bar</field>' +
'<value name="RETURN">' +
@@ -106,7 +106,7 @@ function test_procedureReturnEnablingRemembersOldCallerState() {
procedureSvgTest_setup();
try {
var dom = Blockly.Xml.textToDom(
'<xml xmlns="http://www.w3.org/1999/xhtml">' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="procedures_defreturn" id="bar-def">' +
'<field name="NAME">bar</field>' +
'<value name="RETURN">' +
@@ -165,7 +165,7 @@ function test_procedureNoReturnSetDisabledUpdatesCallers() {
procedureSvgTest_setup();
try {
var dom = Blockly.Xml.textToDom(
'<xml xmlns="http://www.w3.org/1999/xhtml">' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="procedures_defnoreturn" id="bar-def">' +
'<field name="NAME">bar</field>' +
'</block>' +
@@ -224,7 +224,7 @@ function test_procedureNoReturnEnablingRemembersOldCallerState() {
procedureSvgTest_setup();
try {
var dom = Blockly.Xml.textToDom(
'<xml xmlns="http://www.w3.org/1999/xhtml">' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="procedures_defnoreturn" id="bar-def">' +
'<field name="NAME">bar</field>' +
'</block>' +
@@ -285,7 +285,7 @@ function test_procedureEnableDisableInteractions() {
procedureSvgTest_setup();
try {
var dom = Blockly.Xml.textToDom(
'<xml xmlns="http://www.w3.org/1999/xhtml">' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="procedures_defreturn" id="bar-def">' +
'<field name="NAME">bar</field>' +
'<statement name="STACK">' +
@@ -369,5 +369,5 @@ function test_procedureEnableDisableInteractions() {
} finally {
procedureSvgTest_teardown();
}
}
}

View File

@@ -123,7 +123,7 @@ function test_appendDomToWorkspace() {
var workspace = helper_createWorkspaceWithToolbox();
try {
var dom = Blockly.Xml.textToDom(
'<xml xmlns="http://www.w3.org/1999/xhtml">' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
' <block type="math_random_float" inline="true" x="21" y="23">' +
' </block>' +
'</xml>');
@@ -147,7 +147,7 @@ function test_svgDisposeWithShadow() {
var blockNew;
try {
var dom = Blockly.Xml.textToDom(
'<xml xmlns="http://www.w3.org/1999/xhtml">' +
'<xml xmlns="https://developers.google.com/blockly/xml">' +
'<block type="test_val_in">' +
'<value name="NAME">' +
'<shadow type="simple_test_block"></shadow>' +