diff --git a/core/block.js b/core/block.js index 6ea9dcc42..1bbd06dbe 100644 --- a/core/block.js +++ b/core/block.js @@ -1727,6 +1727,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. + * @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. */ Blockly.Block.prototype.removeInput = function(name, opt_quiet) { @@ -1737,10 +1738,12 @@ Blockly.Block.prototype.removeInput = function(name, opt_quiet) { } input.dispose(); this.inputList.splice(i, 1); - return; + return true; } } - if (!opt_quiet) { + if (opt_quiet) { + return false; + } else { throw Error('Input not found: ' + name); } }; diff --git a/core/block_svg.js b/core/block_svg.js index 83af1db30..f359aeda3 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -1390,17 +1390,20 @@ Blockly.BlockSvg.prototype.setInputsInline = function(newBoolean) { * 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. + * @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. */ Blockly.BlockSvg.prototype.removeInput = function(name, opt_quiet) { - Blockly.BlockSvg.superClass_.removeInput.call(this, name, opt_quiet); + var removed = Blockly.BlockSvg.superClass_.removeInput.call(this, name, opt_quiet); if (this.rendered) { this.render(); // Removing an input will cause the block to change shape. this.bumpNeighbours(); } + + return removed; }; /**