Browse Source

Fixed: parent–less ViewCollection should modify DOM.

Aleksander Nowodziński 9 years ago
parent
commit
0d69265bc2
1 changed files with 2 additions and 2 deletions
  1. 2 2
      packages/ckeditor5-ui/src/viewcollection.js

+ 2 - 2
packages/ckeditor5-ui/src/viewcollection.js

@@ -25,14 +25,14 @@ export default class ViewCollection extends Collection {
 
 		// Handle {@link ui.View#element} in DOM when a new view is added to the collection.
 		this.on( 'add', ( evt, view, index ) => {
-			if ( this.ready && view.element ) {
+			if ( this.ready && view.element && this._parentElement ) {
 				this._parentElement.insertBefore( view.element, this._parentElement.children[ index ] );
 			}
 		} );
 
 		// Handle {@link ui.View#element} in DOM when a view is removed from the collection.
 		this.on( 'remove', ( evt, view ) => {
-			if ( this.ready && view.element ) {
+			if ( this.ready && view.element && this._parentElement ) {
 				view.element.remove();
 			}
 		} );