Kaynağa Gözat

View#destroy() should not remove view's #element from DOM.

Aleksander Nowodzinski 8 yıl önce
ebeveyn
işleme
4d0f319195

+ 0 - 4
packages/ckeditor5-ui/src/view.js

@@ -319,10 +319,6 @@ export default class View {
 		this._unboundChildren.clear();
 		this._viewCollections.clear();
 
-		if ( this.element ) {
-			this.element.remove();
-		}
-
 		this.element = this.template = this.locale = this.t =
 			this._viewCollections = this._unboundChildren = null;
 

+ 4 - 4
packages/ckeditor5-ui/tests/view.js

@@ -272,14 +272,14 @@ describe( 'View', () => {
 			} );
 		} );
 
-		it( 'detaches the element from DOM', () => {
+		it( 'leaves the #element in DOM', () => {
 			const elRef = view.element;
+			const parentEl = document.createElement( 'div' );
 
-			document.createElement( 'div' ).appendChild( view.element );
-			expect( elRef.parentNode ).to.be.not.null;
+			parentEl.appendChild( view.element );
 
 			return view.destroy().then( () => {
-				expect( elRef.parentNode ).to.be.null;
+				expect( elRef.parentNode ).to.equal( parentEl );
 			} );
 		} );