Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 30434e2

Browse files
madflowdeeg
authored andcommitted
fix: unbind refresh event listener
Stops memory leaks on orphan refresh event listeners. Fixes #339 Closes #272
1 parent 0807893 commit 30434e2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-ui-tinymce",
3-
"version": "0.0.18",
3+
"version": "0.0.19",
44
"descriptin": "This directive allows you to add a tinymce to your form elements.",
55
"author": "https://github.com/angular-ui/ui-tinymce/graphs/contributors",
66
"license": "MIT",

src/tinymce.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ angular.module('ui.tinymce', [])
179179
// This block is because of TinyMCE not playing well with removal and
180180
// recreation of instances, requiring instances to have different
181181
// selectors in order to render new instances properly
182-
scope.$on('$tinymce:refresh', function(e, id) {
182+
var unbindEventListener = scope.$on('$tinymce:refresh', function(e, id) {
183183
var eid = attrs.id;
184184
if (angular.isUndefined(id) || id === eid) {
185185
var parentElement = element.parent();
@@ -189,6 +189,7 @@ angular.module('ui.tinymce', [])
189189
clonedElement.removeAttr('aria-hidden');
190190
tinymce.execCommand('mceRemoveEditor', false, eid);
191191
parentElement.append($compile(clonedElement)(scope));
192+
unbindEventListener();
192193
}
193194
});
194195

0 commit comments

Comments
 (0)