mirror of
https://github.com/google/blockly.git
synced 2026-01-19 14:57:12 +01:00
@@ -1806,7 +1806,7 @@ Blockly.Block.prototype.moveNumberedInputBefore = function(
|
||||
/**
|
||||
* Remove an input from this block.
|
||||
* @param {string} name The name of the input.
|
||||
* @param {boolean=} opt_quiet True to prevent error if input is not present.
|
||||
* @param {boolean=} opt_quiet True to prevent an error if input is not present.
|
||||
* @return {boolean} True if operation succeeds, false if input is not present and opt_quiet is true
|
||||
* @throws {Error} if the input is not present and opt_quiet is not true.
|
||||
*/
|
||||
|
||||
@@ -134,9 +134,12 @@ Blockly.Input.prototype.insertFieldAt = function(index, field, opt_name) {
|
||||
/**
|
||||
* Remove a field from this input.
|
||||
* @param {string} name The name of the field.
|
||||
* @throws {Error} if the field is not present.
|
||||
* @param {boolean=} opt_quiet True to prevent an error if field is not present.
|
||||
* @return {boolean} True if operation succeeds, false if field is not present
|
||||
* and opt_quiet is true.
|
||||
* @throws {Error} if the field is not present and opt_quiet is false.
|
||||
*/
|
||||
Blockly.Input.prototype.removeField = function(name) {
|
||||
Blockly.Input.prototype.removeField = function(name, opt_quiet) {
|
||||
for (var i = 0, field; (field = this.fieldRow[i]); i++) {
|
||||
if (field.name === name) {
|
||||
field.dispose();
|
||||
@@ -147,10 +150,14 @@ Blockly.Input.prototype.removeField = function(name) {
|
||||
// Removing a field will cause the block to change shape.
|
||||
this.sourceBlock_.bumpNeighbours();
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
throw Error('Field "%s" not found.', name);
|
||||
if (opt_quiet) {
|
||||
return false;
|
||||
} else {
|
||||
throw Error('Field "' + name + '" not found.');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user