8
0
Просмотр исходного кода

Made ContextualBalloon#destroy() less intrusive and repeatable, leaving UI destruction to the View and ViewCollection tree.

Aleksander Nowodzinski 8 лет назад
Родитель
Сommit
9af5928dde

+ 0 - 10
packages/ckeditor5-ui/src/panel/balloon/contextualballoon.js

@@ -205,14 +205,4 @@ export default class ContextualBalloon extends Plugin {
 	_getBalloonPosition() {
 		return this._stack.values().next().value.position;
 	}
-
-	/**
-	 * @inheritDoc
-	 */
-	destroy() {
-		this.editor.ui.view.body.remove( this.view );
-		this.view.destroy();
-		this._stack.clear();
-		super.destroy();
-	}
 }

+ 9 - 3
packages/ckeditor5-ui/tests/panel/balloon/contextualballoon.js

@@ -352,11 +352,17 @@ describe( 'ContextualBalloon', () => {
 	} );
 
 	describe( 'destroy()', () => {
-		it( 'should remove balloon panel view from editor body collection and clear stack', () => {
+		it( 'can be called multiple times', () => {
+			expect( () => {
+				balloon.destroy();
+				balloon.destroy();
+			} ).to.not.throw();
+		} );
+
+		it( 'should not touch the DOM', () => {
 			balloon.destroy();
 
-			expect( editor.ui.view.body.getIndex( balloon.view ) ).to.equal( -1 );
-			expect( balloon.visibleView ).to.null;
+			expect( editor.ui.view.body.getIndex( balloon.view ) ).to.not.equal( -1 );
 		} );
 	} );
 } );