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

Commit

Permalink
Merge pull request #1635 from ckeditor/t/ckeditor5/1341
Browse files Browse the repository at this point in the history
Fix: There should be no memory leaks when the editor is created and destroyed (see ckeditor/ckeditor5#1341).
  • Loading branch information
oleq authored Jan 22, 2019
2 parents ca21a66 + 3588160 commit bf86ffa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/controller/datacontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ export default class DataController {
/**
* Removes all event listeners set by the DataController.
*/
destroy() {}
destroy() {
this.stopListening();
}

/**
* Checks if all provided root names are existing editor roots.
Expand Down
8 changes: 8 additions & 0 deletions src/view/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ export default class Document {
this._postFixers.add( postFixer );
}

/**
* Destroys this instance. Makes sure that all observers are destroyed and listeners removed.
*/
destroy() {
this.roots.map( root => root.destroy() );
this.stopListening();
}

/**
* Performs post-fixer loops. Executes post-fixer callbacks as long as none of them has done any changes to the model.
*
Expand Down
4 changes: 4 additions & 0 deletions src/view/editableelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export default class EditableElement extends ContainerElement {
}
}

destroy() {
this.stopListening();
}

/**
* Returns document associated with the editable.
*
Expand Down
2 changes: 2 additions & 0 deletions src/view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ export default class View {
observer.destroy();
}

this.document.destroy();

this.stopListening();
}

Expand Down

0 comments on commit bf86ffa

Please sign in to comment.