Fix memory leak in quick reply

This commit is contained in:
discomrade 2021-07-25 01:59:13 -02:00 committed by towards-a-new-leftypol
parent 71aca6040b
commit b58ac72acd
1 changed files with 5 additions and 1 deletions

View File

@ -293,7 +293,7 @@
$postForm.appendTo($('body')).hide(); $postForm.appendTo($('body')).hide();
$origPostForm = $('form[name="post"]:first'); $origPostForm = $('form[name="post"]:first');
// Synchronise body text with original post form // Synchronise body text with original post form. Remember to remove listeners when closing.
$origPostForm.find('textarea[name="body"]').on('change input propertychange', function() { $origPostForm.find('textarea[name="body"]').on('change input propertychange', function() {
$postForm.find('textarea[name="body"]').val($(this).val()); $postForm.find('textarea[name="body"]').val($(this).val());
}); });
@ -346,6 +346,10 @@
} }
$postForm.find('th .close-btn').click(function() { $postForm.find('th .close-btn').click(function() {
// Remove origPostForm listeners
$origPostForm.find('textarea[name="body"]').off('change input propertychange focus');
$origPostForm.find('input[type="text"],select').off('change input propertychange');
$origPostForm.find('textarea[name="body"]').attr('id', 'body'); $origPostForm.find('textarea[name="body"]').attr('id', 'body');
$postForm.remove(); $postForm.remove();
floating_link(); floating_link();