Make block.removeInput return a boolean. (#3832)

Make block.removeInput return a boolean.
This commit is contained in:
Maribeth Bottorff
2020-04-17 17:47:58 -07:00
committed by GitHub
parent 17eade1017
commit 781dbd974d
2 changed files with 9 additions and 3 deletions

View File

@@ -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);
}
};

View File

@@ -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;
};
/**