Mathijs den Burger pushed to branch feature/visual-editing-psp2-CHANNELMGR-1065 
at cms-community / hippo-addon-channel-manager


Commits:
1b79adbd by Mathijs den Burger at 2017-03-03T10:52:01+01:00
CHANNELMGR-1065 Destroy editor when scope is destroyed

Otherwise the number of open editor instances will grow indefinitely.

- - - - -


2 changed files:

- 
frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/fields/ckeditor.directive.js
- 
frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/fields/ckeditor.directive.spec.js


Changes:

=====================================
frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/fields/ckeditor.directive.js
=====================================
--- 
a/frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/fields/ckeditor.directive.js
+++ 
b/frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/fields/ckeditor.directive.js
@@ -81,6 +81,10 @@ function ckeditor($window, ConfigService) {
           ngModel.$setViewValue(html);
         });
       });
+
+      scope.$on('$destroy', () => {
+        editor.destroy();
+      });
     },
   };
 }


=====================================
frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/fields/ckeditor.directive.spec.js
=====================================
--- 
a/frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/fields/ckeditor.directive.spec.js
+++ 
b/frontend-ng/src/angularjs/channel/sidePanels/rightSidePanel/fields/ckeditor.directive.spec.js
@@ -35,6 +35,7 @@ describe('ckeditor directive', () => {
     beforeEach(() => {
       CKEDITOR = jasmine.createSpyObj('CKEDITOR', ['replace']);
       editor = jasmine.createSpyObj('editor', [
+        'destroy',
         'getData',
         'on',
         'setData',
@@ -80,6 +81,12 @@ describe('ckeditor directive', () => {
 
       expect(scope.value).toBe(newValue);
     });
+
+    it('destroys the editor the scope is destroyed', () => {
+      compile();
+      scope.$destroy();
+      expect(editor.destroy).toHaveBeenCalled();
+    });
   });
 
   describe('without a model', () => {



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/1b79adbdea2bd6213eb7d0fbe43577ba74d77c9f
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to