From 2474ec53ab42a8eed2140b3f7150875f21b8ad48 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 27 Jan 2017 11:33:04 -0800 Subject: [PATCH] Stop bumping neighbours in headless blockly --- core/connection.js | 20 +++++++++++++------- core/rendered_connection.js | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/core/connection.js b/core/connection.js index 3b8c82af8..dda3d4fe5 100644 --- a/core/connection.js +++ b/core/connection.js @@ -571,6 +571,18 @@ Blockly.Connection.prototype.checkType_ = function(otherConnection) { return false; }; +/** + * Function to be called when this connection's compatible types have changed. + * @private + */ +Blockly.Connection.prototype.onCheckChanged_ = function() { + // The new value type may not be compatible with the existing connection. + if (this.isConnected() && !this.checkType_(this.targetConnection)) { + var child = this.isSuperior() ? this.targetBlock() : this.sourceBlock_; + child.unplug(); + } +}; + /** * Change a connection's compatibility. * @param {*} check Compatible value type or list of value types. @@ -585,13 +597,7 @@ Blockly.Connection.prototype.setCheck = function(check) { check = [check]; } this.check_ = check; - // The new value type may not be compatible with the existing connection. - if (this.isConnected() && !this.checkType_(this.targetConnection)) { - var child = this.isSuperior() ? this.targetBlock() : this.sourceBlock_; - child.unplug(); - // Bump away. - this.sourceBlock_.bumpNeighbours_(); - } + this.onCheckChanged_(); } else { this.check_ = null; } diff --git a/core/rendered_connection.js b/core/rendered_connection.js index 8a67d3d86..6425dcdfc 100644 --- a/core/rendered_connection.js +++ b/core/rendered_connection.js @@ -393,3 +393,17 @@ Blockly.RenderedConnection.prototype.connect_ = function(childConnection) { } } }; + +/** + * Function to be called when this connection's compatible types have changed. + * @private + */ +Blockly.RenderedConnection.prototype.onCheckChanged_ = function() { + // The new value type may not be compatible with the existing connection. + if (this.isConnected() && !this.checkType_(this.targetConnection)) { + var child = this.isSuperior() ? this.targetBlock() : this.sourceBlock_; + child.unplug(); + // Bump away. + this.sourceBlock_.bumpNeighbours_(); + } +};