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

Commit

Permalink
Merge aa9666b into 2f7b744
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Jan 15, 2019
2 parents 2f7b744 + aa9666b commit 63c2158
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/controller/datacontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,14 @@ export default class DataController {
/**
* Removes all event listeners set by the DataController.
*/
destroy() {}
destroy() {
this.stopListening();
this.model = null;
this.processor = null;
this.mapper = null;
this.downcastDispatcher = null;
this.upcastDispatcher = null;
}

/**
* Checks if all provided root names are existing editor roots.
Expand Down
4 changes: 4 additions & 0 deletions src/controller/editingcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ export default class EditingController {
*/
destroy() {
this.view.destroy();
this.view = null;
this.model = null;
this.mapper = null;
this.history = null;
this.stopListening();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/model/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ export default class Document {
destroy() {
this.selection.destroy();
this.stopListening();
this.selection = null;
this.model = null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/model/documentselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export default class DocumentSelection {
*/
destroy() {
this._selection.destroy();
this._selection = null;
}

/**
Expand Down Expand Up @@ -666,6 +667,7 @@ class LiveSelection extends Selection {
for ( let i = 0; i < this._ranges.length; i++ ) {
this._ranges[ i ].detach();
}
this.markers = null;

this.stopListening();
}
Expand Down
3 changes: 3 additions & 0 deletions src/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,10 @@ export default class Model {
*/
destroy() {
this.document.destroy();
this.document = null;
this.stopListening();
this.markers = null;
this.document = null;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/view/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ export default class Document {
this._postFixers.add( postFixer );
}

destroy() {
this.roots.map( root => root.destroy() );
this.roots.clear();
this.roots = null;
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
1 change: 1 addition & 0 deletions src/view/filler.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const BR_FILLER = domDocument => {
* @function
*/
export const NBSP_FILLER = domDocument => domDocument.createTextNode( '\u00A0' );
// TODO: The NBSP_FILLER leaks detachted textNode.

/**
* Length of the {@link module:engine/view/filler~INLINE_FILLER INLINE_FILLER}.
Expand Down
1 change: 1 addition & 0 deletions src/view/observer/fakeselectionobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default class FakeSelectionObserver extends Observer {
super.destroy();

this._fireSelectionChangeDoneDebounced.cancel();
this._fireSelectionChangeDoneDebounced = null;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/view/observer/mutationobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ export default class MutationObserver extends Observer {
super.destroy();

this._mutationObserver.disconnect();

this.domConverter = null;
this.renderer = null;
this._domElements = null;
this._mutationObserver = null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/view/observer/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export default class Observer {
destroy() {
this.disable();
this.stopListening();
this.view = null;
this.document = null;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/view/observer/selectionobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ export default class SelectionObserver extends Observer {

clearInterval( this._clearInfiniteLoopInterval );
this._fireSelectionChangeDoneDebounced.cancel();

this._fireSelectionChangeDoneDebounced = null;
this._clearInfiniteLoopInterval = null;

this.mutationObserver = null;
this.selection = null;
this.domConverter = null;
this._documents = null;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,15 @@ export default class View {
observer.destroy();
}

this.document.destroy();

this.stopListening();
this.document = null;
this.domConverter = null;
this._renderer = null;
this._writer = null;
this.domRoots.clear();
this.domRoots = null;
}

/**
Expand Down

0 comments on commit 63c2158

Please sign in to comment.