diff --git a/core/block.js b/core/block.js index 0e81acc1e..6ca76b4a2 100644 --- a/core/block.js +++ b/core/block.js @@ -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. */ diff --git a/core/input.js b/core/input.js index 2c6dae005..ab6db5303 100644 --- a/core/input.js +++ b/core/input.js @@ -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.'); + } }; /**