Fix parasitic transitivity of setPreviousStatement and setNextStatement.

This commit is contained in:
Neil Fraser
2014-11-04 12:27:27 -08:00
parent c31e8dc4ca
commit 01a9750806
2 changed files with 10 additions and 5 deletions

View File

@@ -104,8 +104,7 @@ Blockly.Connection.prototype.connect = function(otherConnection) {
// block. Since this block may be a row, walk down to the end.
var newBlock = this.sourceBlock_;
var connection;
while (connection =
Blockly.Connection.singleConnection_(
while (connection = Blockly.Connection.singleConnection_(
/** @type {!Blockly.Block} */ (newBlock), orphanBlock)) {
// '=' is intentional in line above.
if (connection.targetBlock()) {
@@ -144,8 +143,11 @@ Blockly.Connection.prototype.connect = function(otherConnection) {
if (newBlock.nextConnection.targetConnection) {
newBlock = newBlock.getNextBlock();
} else {
newBlock.nextConnection.connect(orphanBlock.previousConnection);
orphanBlock = null;
if (orphanBlock.previousConnection.checkType_(
newBlock.nextConnection)) {
newBlock.nextConnection.connect(orphanBlock.previousConnection);
orphanBlock = null;
}
break;
}
}
@@ -448,6 +450,7 @@ Blockly.Connection.prototype.closest = function(maxLimit, dx, dy) {
* @return {boolean} True if the search needs to continue: either the current
* connection's vertical distance from the other connection is less than
* the allowed radius, or if the connection is not compatible.
* @private
*/
function checkConnection_(yIndex) {
var connection = db[yIndex];
@@ -486,6 +489,7 @@ Blockly.Connection.prototype.closest = function(maxLimit, dx, dy) {
targetSourceBlock = targetSourceBlock.getParent();
} while (targetSourceBlock);
// Only connections within the maxLimit radius.
var dx = currentX - db[yIndex].x_;
var dy = currentY - db[yIndex].y_;
var r = Math.sqrt(dx * dx + dy * dy);

View File

@@ -86,7 +86,8 @@ Blockly.JavaScript['unittest_main'].defineAssert_ = function(block) {
' function equals(a, b) {',
' if (a === b) {',
' return true;',
' } else if ((typeof a == "number") && (typeof b == "number") && (a.toPrecision(15) == b.toPrecision(15))) {',
' } else if ((typeof a == "number") && (typeof b == "number") &&',
' (a.toPrecision(15) == b.toPrecision(15))) {',
' return true;',
' } else if (a instanceof Array && b instanceof Array) {',
' if (a.length != b.length) {',