mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
Merge "Destroy test surfaces"
This commit is contained in:
commit
846414f215
|
@ -302,6 +302,7 @@ ve.ce.Surface.prototype.disable = function () {
|
|||
* @method
|
||||
*/
|
||||
ve.ce.Surface.prototype.destroy = function () {
|
||||
this.surfaceObserver.detach();
|
||||
this.documentView.getDocumentNode().setLive( false );
|
||||
this.$.remove();
|
||||
this.$phantoms.remove();
|
||||
|
|
|
@ -80,6 +80,16 @@ ve.ce.SurfaceObserver.prototype.clear = function ( range ) {
|
|||
this.hash = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Detach from the document view
|
||||
*
|
||||
* @method
|
||||
*/
|
||||
ve.ce.SurfaceObserver.prototype.detach = function () {
|
||||
this.documentView = null;
|
||||
this.domDocument = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Start the setTimeout synchronisation loop
|
||||
*
|
||||
|
@ -165,6 +175,10 @@ ve.ce.SurfaceObserver.prototype.pollOnceNoEmit = function () {
|
|||
ve.ce.SurfaceObserver.prototype.pollOnceInternal = function ( emitChanges ) {
|
||||
var $nodeOrSlug, node, text, hash, range, rangyRange;
|
||||
|
||||
if ( !this.domDocument ) {
|
||||
return;
|
||||
}
|
||||
|
||||
range = this.range;
|
||||
node = this.node;
|
||||
rangyRange = ve.ce.DomRange.newFromDomSelection( rangy.getSelection( this.domDocument ) );
|
||||
|
|
|
@ -217,6 +217,8 @@ QUnit.test( 'onContentChange', function ( assert ) {
|
|||
}
|
||||
assert.deepEqual( ops, expectedOps, msg + ': operations' );
|
||||
assert.deepEqual( surface.getModel().getSelection(), expectedRange, msg + ': range' );
|
||||
|
||||
surface.destroy();
|
||||
}
|
||||
|
||||
for ( i = 0; i < cases.length; i++ ) {
|
||||
|
|
|
@ -96,6 +96,7 @@ QUnit.test( 'getOffsetFrom(Element|Text)Node', function ( assert ) {
|
|||
documentView = surface.getView().getDocument();
|
||||
|
||||
testOffsets( documentView.documentNode.$[0], testCases[i], -1 );
|
||||
surface.destroy();
|
||||
}
|
||||
} );
|
||||
|
||||
|
|
|
@ -154,10 +154,10 @@ ve.ui.Surface.prototype.getCommands = function () {
|
|||
*/
|
||||
ve.ui.Surface.prototype.destroy = function () {
|
||||
ve.instances.splice( ve.instances.indexOf( this ), 1 );
|
||||
this.view.destroy();
|
||||
this.$.remove();
|
||||
this.$globalOverlay.remove();
|
||||
this.$localOverlay.remove();
|
||||
this.view.destroy();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue