Fixed field editor disposal (#3109)

* Fixed field editor disposal.
This commit is contained in:
Beka Westberg
2019-10-08 16:48:31 -07:00
committed by Sam El-Husseini
parent cf04a9529b
commit f4f9a67903
4 changed files with 12 additions and 16 deletions

View File

@@ -304,13 +304,15 @@ Blockly.FieldAngle.prototype.dropdownCreate_ = function() {
};
/**
* Dispose of events belonging to the angle editor.
* Disposes of events and dom-references belonging to the angle editor.
* @private
*/
Blockly.FieldAngle.prototype.dropdownDispose_ = function() {
Blockly.unbindEvent_(this.clickWrapper_);
Blockly.unbindEvent_(this.clickSurfaceWrapper_);
Blockly.unbindEvent_(this.moveSurfaceWrapper_);
this.gauge_ = null;
this.line_ = null;
};
/**

View File

@@ -556,7 +556,7 @@ Blockly.FieldColour.prototype.dropdownCreate_ = function() {
};
/**
* Dispose of events belonging to the colour editor.
* Disposes of events and dom-references belonging to the colour editor.
* @private
*/
Blockly.FieldColour.prototype.dropdownDispose_ = function() {

View File

@@ -269,7 +269,7 @@ Blockly.FieldDropdown.prototype.dropdownCreate_ = function() {
};
/**
* Dispose of events belonging to the dropdown editor.
* Disposes of events and dom-references belonging to the dropdown editor.
* @private
*/
Blockly.FieldDropdown.prototype.dropdownDispose_ = function() {

View File

@@ -292,34 +292,28 @@ Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
};
/**
* Close the editor, save the results, and dispose any events bound to the
* text input's editor.
* Closes the editor, saves the results, and disposes of any events or
* dom-references belonging to the editor.
* @private
*/
Blockly.FieldTextInput.prototype.widgetDispose_ = function() {
// Finalize value.
// Non-disposal related things that we do when the editor closes.
this.isBeingEdited_ = false;
this.isTextValid_ = true;
// Always re-render when the we close the editor as value
// set on the field's node may be inconsistent with the field's
// internal value.
// Make sure the field's node matches the field's internal value.
this.forceRerender();
// Call onFinishEditing
// TODO: Get rid of this or make it less of a hack.
// TODO(#2496): Make this less of a hack.
if (this.onFinishEditing_) {
this.onFinishEditing_(this.value_);
}
// Remove htmlInput events.
// Actual disposal.
this.unbindInputEvents_();
// Delete style properties.
var style = Blockly.WidgetDiv.DIV.style;
style.width = 'auto';
style.height = 'auto';
style.fontSize = '';
this.htmlInput_ = null;
};
/**