瀏覽代碼

Fixed: parent–less ViewCollection should modify DOM.

Aleksander Nowodziński 9 年之前
父節點
當前提交
0d69265bc2
共有 1 個文件被更改,包括 2 次插入2 次删除
  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();
 			}
 		} );