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_(); + } +};