Allow terminal blocks to replace other terminal blocks (#433)

* Allow terminal blocks to replace other terminal blocks

* Updated test to allow replacing terminal blocks
This commit is contained in:
rachel-fenichel 2016-06-17 14:34:28 -07:00 committed by Neil Fraser
parent 3ffd7a2d27
commit 7a1db20765
2 changed files with 8 additions and 3 deletions

View file

@ -370,10 +370,14 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate) {
}
// Don't let a block with no next connection bump other blocks out of the
// stack.
// stack. But covering up a shadow block or stack of shadow blocks is fine.
// Similarly, replacing a terminal statement with another terminal statement
// is allowed.
if (this.type == Blockly.PREVIOUS_STATEMENT &&
candidate.isConnected() &&
!this.sourceBlock_.nextConnection) {
!this.sourceBlock_.nextConnection &&
!candidate.targetBlock().isShadow() &&
candidate.targetBlock().nextConnection) {
return false;
}

View file

@ -309,7 +309,8 @@ function test_isConnectionAllowed_NoNext() {
three.sourceBlock_.previousConnection = three;
Blockly.Connection.connectReciprocally_(one, three);
assertFalse(two.isConnectionAllowed(one));
// A terminal block is allowed to replace another terminal block.
assertTrue(two.isConnectionAllowed(one));
}
function testCheckConnection_Okay() {