mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Stop calling onchange on deleted blocks.
This commit is contained in:
@@ -310,13 +310,9 @@ Blockly.Blocks['logic_compare'] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function() {
|
||||
if (!this.workspace) {
|
||||
// Block has been deleted.
|
||||
return;
|
||||
}
|
||||
var blockA = this.getInputTargetBlock('A');
|
||||
var blockB = this.getInputTargetBlock('B');
|
||||
// Kick blocks that existed prior to this change if they don't match.
|
||||
// Disconnect blocks that existed prior to this change if they don't match.
|
||||
if (blockA && blockB &&
|
||||
!blockA.outputConnection.checkType_(blockB.outputConnection)) {
|
||||
// Mismatch between two inputs. Disconnect previous and bump it away.
|
||||
@@ -445,14 +441,10 @@ Blockly.Blocks['logic_ternary'] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function() {
|
||||
if (!this.workspace) {
|
||||
// Block has been deleted.
|
||||
return;
|
||||
}
|
||||
var blockA = this.getInputTargetBlock('THEN');
|
||||
var blockB = this.getInputTargetBlock('ELSE');
|
||||
var parentConnection = this.outputConnection.targetConnection;
|
||||
// Kick blocks that existed prior to this change if they don't match.
|
||||
// Disconnect blocks that existed prior to this change if they don't match.
|
||||
if ((blockA || blockB) && parentConnection) {
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var block = (i == 1) ? blockA : blockB;
|
||||
|
||||
@@ -295,12 +295,8 @@ Blockly.Blocks['controls_flow_statements'] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function() {
|
||||
if (!this.workspace) {
|
||||
// Block has been deleted.
|
||||
return;
|
||||
}
|
||||
var legal = false;
|
||||
// Is the block nested in a control statement?
|
||||
// Is the block nested in a loop?
|
||||
var block = this;
|
||||
do {
|
||||
if (block.type == 'controls_repeat' ||
|
||||
|
||||
@@ -733,10 +733,6 @@ Blockly.Blocks['procedures_ifreturn'] = {
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function() {
|
||||
if (!this.workspace) {
|
||||
// Block has been deleted.
|
||||
return;
|
||||
}
|
||||
var legal = false;
|
||||
// Is the block nested in a procedure?
|
||||
var block = this;
|
||||
|
||||
Reference in New Issue
Block a user