More field dispose (#3201)

* Dispose of element references in fields.
* Fewer warnings
This commit is contained in:
Sam El-Husseini
2019-10-15 17:56:53 -05:00
committed by GitHub
parent e411077b9f
commit 2224bb2a4e
10 changed files with 308 additions and 85 deletions

View File

@@ -83,6 +83,39 @@ Blockly.FieldAngle = function(opt_value, opt_validator, opt_config) {
Blockly.FieldAngle.superClass_.constructor.call(
this, opt_value || 0, opt_validator, opt_config);
/**
* The angle picker's gauge path depending on the value.
* @type {SVGElement}
*/
this.gauge_ = null;
/**
* The angle picker's line drawn representing the value's angle.
* @type {SVGElement}
*/
this.line_ = null;
/**
* Wrapper click event data.
* @type {?Blockly.EventData}
* @private
*/
this.clickWrapper_ = null;
/**
* Surface click event data.
* @type {?Blockly.EventData}
* @private
*/
this.clickSurfaceWrapper_ = null;
/**
* Surface mouse move event data.
* @type {?Blockly.EventData}
* @private
*/
this.moveSurfaceWrapper_ = null;
};
Blockly.utils.object.inherits(Blockly.FieldAngle, Blockly.FieldTextInput);
@@ -309,9 +342,15 @@ Blockly.FieldAngle.prototype.dropdownCreate_ = function() {
* @private
*/
Blockly.FieldAngle.prototype.dropdownDispose_ = function() {
Blockly.unbindEvent_(this.clickWrapper_);
Blockly.unbindEvent_(this.clickSurfaceWrapper_);
Blockly.unbindEvent_(this.moveSurfaceWrapper_);
if (this.clickWrapper_) {
Blockly.unbindEvent_(this.clickWrapper_);
}
if (this.clickSurfaceWrapper_) {
Blockly.unbindEvent_(this.clickSurfaceWrapper_);
}
if (this.moveSurfaceWrapper_) {
Blockly.unbindEvent_(this.moveSurfaceWrapper_);
}
this.gauge_ = null;
this.line_ = null;
};