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

Commit

Permalink
fix: unbind refresh event listener
Browse files Browse the repository at this point in the history
Stops memory leaks on orphan refresh event listeners.

Fixes #339
Closes #272
  • Loading branch information
madflow authored and deeg committed Jul 7, 2017
1 parent 0807893 commit 30434e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-ui-tinymce",
"version": "0.0.18",
"version": "0.0.19",
"descriptin": "This directive allows you to add a tinymce to your form elements.",
"author": "https://github.com/angular-ui/ui-tinymce/graphs/contributors",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion src/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ angular.module('ui.tinymce', [])
// This block is because of TinyMCE not playing well with removal and
// recreation of instances, requiring instances to have different
// selectors in order to render new instances properly
scope.$on('$tinymce:refresh', function(e, id) {
var unbindEventListener = scope.$on('$tinymce:refresh', function(e, id) {
var eid = attrs.id;
if (angular.isUndefined(id) || id === eid) {
var parentElement = element.parent();
Expand All @@ -189,6 +189,7 @@ angular.module('ui.tinymce', [])
clonedElement.removeAttr('aria-hidden');
tinymce.execCommand('mceRemoveEditor', false, eid);
parentElement.append($compile(clonedElement)(scope));
unbindEventListener();
}
});

Expand Down

0 comments on commit 30434e2

Please sign in to comment.