From b58ac72acd0f9a388ee0eb905136ba650cd6c150 Mon Sep 17 00:00:00 2001 From: discomrade Date: Sun, 25 Jul 2021 01:59:13 -0200 Subject: [PATCH] Fix memory leak in quick reply --- js/quick-reply.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/quick-reply.js b/js/quick-reply.js index 926e5880..b2833255 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -293,7 +293,7 @@ $postForm.appendTo($('body')).hide(); $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() { $postForm.find('textarea[name="body"]').val($(this).val()); }); @@ -346,6 +346,10 @@ } $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'); $postForm.remove(); floating_link();