Forbid any ancestor of the block containing the marked connection from being moved to said connection.

This commit is contained in:
Sean Lip
2016-07-01 15:17:32 -07:00
parent 707c2149f1
commit a8bfc38545

View File

@@ -46,13 +46,20 @@ blocklyApp.ClipboardService = ng.core
this.areConnectionsCompatible_(connection, nextConnection));
},
isMovableToMarkedConnection: function(block) {
// It should not be possible to move a block to one of its own
// connections.
if (this.markedConnection_ &&
this.markedConnection_.sourceBlock_.id == block.id) {
// It should not be possible to move any ancestor of the block containing
// the marked spot to the marked spot.
if (!this.markedConnection_) {
return false;
}
var markedSpotAncestorBlock = this.markedConnection_.getSourceBlock();
while (markedSpotAncestorBlock) {
if (markedSpotAncestorBlock.id == block.id) {
return false;
}
markedSpotAncestorBlock = markedSpotAncestorBlock.getParent();
}
return this.canBeCopiedToMarkedConnection(block);
},
canBeCopiedToMarkedConnection: function(block) {