Merge pull request #2355 from alschmiedt/unplug_fix

Adds check for a targetConnection
This commit is contained in:
alschmiedt
2019-04-02 17:18:07 -07:00
committed by GitHub
2 changed files with 9 additions and 4 deletions

View File

@@ -397,8 +397,12 @@ Blockly.Block.prototype.unplugFromRow_ = function(opt_healStack) {
};
/**
* Returns the connection on the only value input on the block, or null if the
* number of value inputs is not one.
* Returns the connection on the value input that is connected to another block.
* When an insertion marker is connected to a connection with a block already
* attached, the connected block is attached to the insertion marker.
* Since only one block can be displaced and attached to the insertion marker
* this should only ever return one connection.
*
* @return {Blockly.Connection} The connection on the value input, or null.
* @private
*/
@@ -406,7 +410,8 @@ Blockly.Block.prototype.getOnlyValueConnection_ = function() {
var connection = null;
for (var i = 0; i < this.inputList.length; i++) {
var thisConnection = this.inputList[i].connection;
if (thisConnection && thisConnection.type == Blockly.INPUT_VALUE) {
if (thisConnection && thisConnection.type == Blockly.INPUT_VALUE
&& thisConnection.targetConnection) {
if (connection) {
return null; // More than one value input found.
}

View File

@@ -238,7 +238,7 @@ function test_block_row_unplug_multi_inputs_middle() {
// Middle block has multiple inputs.
blocks.B.unplug(true);
assertUnpluggedNoheal(blocks);
assertUnpluggedHealed(blocks);
} finally {
blockTest_tearDown();
}