Fix: There should be no memory leaks when the editor is created and destroyed (see ckeditor/ckeditor5#1341).
@@ -176,6 +176,7 @@ class BootstrapEditorUI {
destroy() {
this.view.editable.destroy();
+ this.view.destroy();
}
// This method activates Bold, Italic, Underline, Undo and Redo buttons in the toolbar.
@@ -254,9 +254,12 @@ export default class BalloonToolbar extends Plugin {
* @inheritDoc
*/
- this._fireSelectionChangeDebounced.cancel();
- this.stopListening();
super.destroy();
+
+ this.stopListening();
+ this._fireSelectionChangeDebounced.cancel();
+ this.toolbarView.destroy();
+ this.focusTracker.destroy();
/**
@@ -151,6 +151,18 @@ export default class BlockToolbar extends Plugin {
+ * @inheritDoc
+ */
+ destroy() {
+ super.destroy();
+ // Destroy created UI components as they are not automatically destroyed (see ckeditor5#1341).
+ this.panelView.destroy();
+ this.buttonView.destroy();
+ }
+ /**
* Creates the {@link #toolbarView}.
*
* @private
@@ -493,6 +493,11 @@ export default class View {
this.stopListening();
this._viewCollections.map( c => c.destroy() );
+ // Template isn't obligatory for views.
+ if ( this.template && this.template._revertData ) {
+ this.template.revert( this.element );
@@ -325,6 +325,8 @@ describe( 'View', () => {
it( 'can be called multiple times', () => {
expect( () => {
view.destroy();
+ view.destroy();
} ).to.not.throw();
} );