Skip to content

Commit 671f5a2

Browse files
committed
Fix memory leak in AttachBody
The `$dropdownContainer` variable wasn't being cleaned up when Select2 was destroyed, which was causing a memory leak. This closes select2#3559. This closes select2#3603.
1 parent 7bc9387 commit 671f5a2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/js/select2/dropdown/attachBody.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ define([
4444
});
4545
};
4646

47+
AttachBody.prototype.destroy = function (decorated) {
48+
decorated.call(this);
49+
50+
this.$dropdownContainer.remove();
51+
};
52+
4753
AttachBody.prototype.position = function (decorated, $dropdown, $container) {
4854
// Clone all of the container classes
4955
$dropdown.attr('class', $container.attr('class'));

0 commit comments

Comments
 (0)