mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Merge pull request #59 from orionhealth/bump-fix
Fix the logic block to bump the correct block.
This commit is contained in:
@@ -312,19 +312,18 @@ Blockly.Blocks['logic_compare'] = {
|
||||
}
|
||||
var blockA = this.getInputTargetBlock('A');
|
||||
var blockB = this.getInputTargetBlock('B');
|
||||
// Keep track of which block was added second
|
||||
// (so the first block may be ejected upon mismatch).
|
||||
if (blockA && !blockB) {
|
||||
this.blockAPriority_ = false;
|
||||
} else if (!blockA && blockB) {
|
||||
this.blockAPriority_ = true;
|
||||
} else if (blockA && blockB &&
|
||||
!blockA.outputConnection.checkType_(blockB.outputConnection)) {
|
||||
// Mismatch between two inputs. Disconnect one and bump it away.
|
||||
var child = this.blockAPriority_ ? blockB : blockA;
|
||||
child.setParent(null);
|
||||
child.bumpNeighbours_();
|
||||
// Kick blocks that existed prior to this change if they don't match
|
||||
if (this.blocks_ && blockA && blockB &&
|
||||
!blockA.outputConnection.checkType_(blockB.outputConnection)) {
|
||||
// Mismatch between two inputs. Disconnect previous and bump it away.
|
||||
goog.array.forEach(this.blocks_, function(e) {
|
||||
if (e === blockA || e === blockB) {
|
||||
e.setParent(null);
|
||||
e.bumpNeighbours_();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.blocks_ = [blockA, blockB];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user