Destroy attached shadow block when input is destroyed.

This commit is contained in:
Neil Fraser
2016-03-26 19:37:12 -07:00
parent 0626724277
commit b8d48ebabe
2 changed files with 10 additions and 3 deletions

View File

@@ -1232,8 +1232,15 @@ Blockly.Block.prototype.removeInput = function(name, opt_quiet) {
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.name == name) {
if (input.connection && input.connection.targetConnection) {
// Disconnect any attached block.
input.connection.targetBlock().unplug();
input.connection.setShadowDom(null);
var block = input.connection.targetBlock();
if (block.isShadow()) {
// Destroy any attached shadow block.
block.dispose();
} else {
// Disconnect any attached normal block.
block.unplug();
}
}
input.dispose();
this.inputList.splice(i, 1);

View File

@@ -499,7 +499,7 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
// Right-click.
this.showContextMenu_(e);
} else if (!this.isMovable()) {
// Allow unmovable blocks to be selected and context menued, but not
// Allow immovable blocks to be selected and context menued, but not
// dragged. Let this event bubble up to document, so the workspace may be
// dragged instead.
return;