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

Commit bf86ffa

Browse files
authoredJan 22, 2019
Merge pull request #1635 from ckeditor/t/ckeditor5/1341
Fix: There should be no memory leaks when the editor is created and destroyed (see ckeditor/ckeditor5#1341).
2 parents ca21a66 + 3588160 commit bf86ffa

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed
 

‎src/controller/datacontroller.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ export default class DataController {
351351
/**
352352
* Removes all event listeners set by the DataController.
353353
*/
354-
destroy() {}
354+
destroy() {
355+
this.stopListening();
356+
}
355357

356358
/**
357359
* Checks if all provided root names are existing editor roots.

‎src/view/document.js

+8
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ export default class Document {
121121
this._postFixers.add( postFixer );
122122
}
123123

124+
/**
125+
* Destroys this instance. Makes sure that all observers are destroyed and listeners removed.
126+
*/
127+
destroy() {
128+
this.roots.map( root => root.destroy() );
129+
this.stopListening();
130+
}
131+
124132
/**
125133
* Performs post-fixer loops. Executes post-fixer callbacks as long as none of them has done any changes to the model.
126134
*

‎src/view/editableelement.js

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ export default class EditableElement extends ContainerElement {
7777
}
7878
}
7979

80+
destroy() {
81+
this.stopListening();
82+
}
83+
8084
/**
8185
* Returns document associated with the editable.
8286
*

‎src/view/view.js

+2
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ export default class View {
398398
observer.destroy();
399399
}
400400

401+
this.document.destroy();
402+
401403
this.stopListening();
402404
}
403405

0 commit comments

Comments
 (0)