Merge "Destroy test surfaces"

This commit is contained in:
jenkins-bot 2013-10-08 09:19:03 +00:00 committed by Gerrit Code Review
commit 846414f215
5 changed files with 19 additions and 1 deletions

View file

@ -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();

View file

@ -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 ) );

View file

@ -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++ ) {

View file

@ -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();
}
} );

View file

@ -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();
};
/**