More code cleanup for review

This commit is contained in:
Rachel Fenichel
2018-01-12 13:28:17 -08:00
parent 1fa27fa043
commit a30ad6ff3a
3 changed files with 8 additions and 25 deletions

View File

@@ -266,14 +266,19 @@ Blockly.VariableMap.prototype.deleteVariableById = function(id) {
*/
Blockly.VariableMap.prototype.deleteVariableInternal_ = function(variable,
uses) {
Blockly.Events.setGroup(true);
var existingGroup = Blockly.Events.getGroup();
if (!existingGroup) {
Blockly.Events.setGroup(true);
}
try {
for (var i = 0; i < uses.length; i++) {
uses[i].dispose(true, false);
}
this.deleteVariable(variable);
} finally {
Blockly.Events.setGroup(false);
if (!existingGroup) {
Blockly.Events.setGroup(false);
}
}
};

View File

@@ -367,7 +367,7 @@ Blockly.Variables.generateVariableFieldXml_ = function(variableModel) {
typeString = '\'\'';
}
var text = '<field name="VAR" id="' + variableModel.getId() +
'" variabletype="' + typeString +
'" variabletype="' + goog.string.htmlEscape(typeString) +
'">' + goog.string.htmlEscape(variableModel.name) + '</field>';
return text;
};

View File

@@ -928,17 +928,6 @@ Blockly.WorkspaceSvg.prototype.refreshToolboxSelection_ = function() {
}
};
/**
* Rename a variable by updating its name in the variable list.
* @param {string} oldName Variable to rename.
* @param {string} newName New variable name.
* @package
*/
Blockly.WorkspaceSvg.prototype.renameVariable = function(oldName, newName) {
Blockly.WorkspaceSvg.superClass_.renameVariable.call(this, oldName, newName);
this.refreshToolboxSelection_();
};
/**
* Rename a variable by updating its name in the variable map. Update the
* flyout to show the renamed variable immediately.
@@ -951,17 +940,6 @@ Blockly.WorkspaceSvg.prototype.renameVariableById = function(id, newName) {
this.refreshToolboxSelection_();
};
/**
* Delete a variable by the passed in name. Update the flyout to show
* immediately that the variable is deleted.
* @param {string} name Name of variable to delete.
* @package
*/
Blockly.WorkspaceSvg.prototype.deleteVariable = function(name) {
Blockly.WorkspaceSvg.superClass_.deleteVariable.call(this, name);
this.refreshToolboxSelection_();
};
/**
* Delete a variable by the passed in ID. Update the flyout to show
* immediately that the variable is deleted.