浏览代码

Internal (ui): Minor code cleanup.

Marek Lewandowski 5 年之前
父节点
当前提交
e2befc89a8
共有 1 个文件被更改,包括 4 次插入7 次删除
  1. 4 7
      packages/ckeditor5-ui/src/toolbar/toolbarview.js

+ 4 - 7
packages/ckeditor5-ui/src/toolbar/toolbarview.js

@@ -276,12 +276,11 @@ export default class ToolbarView extends View {
 	 * @param {module:ui/componentfactory~ComponentFactory} factory A factory producing toolbar items.
 	 */
 	fillFromConfig( config, factory ) {
-		const toolbarItems = [];
-		config.map( name => {
+		this.items.addMany( config.map( name => {
 			if ( name == '|' ) {
-				toolbarItems.push( new ToolbarSeparatorView() );
+				return new ToolbarSeparatorView();
 			} else if ( factory.has( name ) ) {
-				toolbarItems.push( factory.create( name ) );
+				return factory.create( name );
 			} else {
 				/**
 				 * There was a problem processing the configuration of the toolbar. The item with the given
@@ -303,9 +302,7 @@ export default class ToolbarView extends View {
 				console.warn( attachLinkToDocumentation(
 					'toolbarview-item-unavailable: The requested toolbar item is unavailable.' ), { name } );
 			}
-		} );
-
-		this.items.addMany( toolbarItems );
+		} ).filter( item => item !== undefined ) );
 	}
 }