mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
Fix unit tests
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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_);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user