mirror of
https://github.com/google/blockly.git
synced 2026-01-11 02:47:09 +01:00
Make block.removeInput return a boolean. (#3832)
Make block.removeInput return a boolean.
This commit is contained in:
committed by
GitHub
parent
17eade1017
commit
781dbd974d
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user