Skip to content

Commit

Permalink
Merge pull request #171 from Rincelent/memory-leak-select
Browse files Browse the repository at this point in the history
Fixed a memory leak on Select widget
  • Loading branch information
flozz authored Mar 31, 2023
2 parents d28513c + 2c013f9 commit 7ddc215
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/composite/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ var Select = Widget.$extend({
}

this._value = "";
var item = new MenuItem({text: this.placeholder, className: "photonui-select-placeholder"});
if (this.__displayValue) {
this.__displayValue.destroy();
}
this.__displayValue = new MenuItem({text: this.placeholder, className: "photonui-select-placeholder"});
Helpers.cleanNode(this.__html.select);
this.__html.select.appendChild(item.html);
this.__html.select.appendChild(this.__displayValue.html);
},

/**
Expand Down Expand Up @@ -325,7 +328,12 @@ var Select = Widget.$extend({
* @method destroy
*/
destroy: function () {
this.__popupMenu.destroy();
if (this.__displayValue) {
this.__displayValue.destroy();
}
if (this.__popupMenu) {
this.__popupMenu.destroy();
}
this.$super();
},

Expand Down

0 comments on commit 7ddc215

Please sign in to comment.