From 1085fd29be25147c393ba8b721f2c6034bc5c48b Mon Sep 17 00:00:00 2001 From: Hamish Friedlander Date: Thu, 14 Jun 2012 14:33:50 +1200 Subject: [PATCH] BUGFIX: TinyMCE isnt unbinding formatselect or styleselect which leaks memory. We should really fix TinyMCE, but lets just brute-force it for now. --- javascript/HtmlEditorField.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/javascript/HtmlEditorField.js b/javascript/HtmlEditorField.js index e29116fdd..5fb04675e 100644 --- a/javascript/HtmlEditorField.js +++ b/javascript/HtmlEditorField.js @@ -216,7 +216,21 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE; }, onremove: function() { var ed = tinyMCE.get(this.attr('id')); - if (ed) ed.remove(); + if (ed) { + ed.remove(); + + // TinyMCE leaves behind events. We should really fix TinyMCE, but lets brute force it for now + $.each(jQuery.cache, function(){ + var source = this.handle && this.handle.elem; + if (!source) return; + + var parent = source; + while (parent && parent.nodeType == 1) parent = parent.parentNode; + + if (!parent) $(source).unbind().remove(); + }) + } + this._super(); },