mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
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:
parent
3ffd7a2d27
commit
7a1db20765
2 changed files with 8 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue