浏览代码

Merge branch 'master' into t/ckeditor5-alignment/16

Piotrek Koszuliński 7 年之前
父节点
当前提交
43a5f64ade
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 5 3
      packages/ckeditor5-ui/src/componentfactory.js
  2. 7 1
      packages/ckeditor5-ui/tests/componentfactory.js

+ 5 - 3
packages/ckeditor5-ui/src/componentfactory.js

@@ -62,7 +62,9 @@ export default class ComponentFactory {
 	 * @returns {Iterable.<String>}
 	 */
 	* names() {
-		yield* this._components.keys();
+		for ( const value of this._components.values() ) {
+			yield value.originalName;
+		}
 	}
 
 	/**
@@ -87,7 +89,7 @@ export default class ComponentFactory {
 			);
 		}
 
-		this._components.set( getNormalized( name ), callback );
+		this._components.set( getNormalized( name ), { callback, originalName: name } );
 	}
 
 	/**
@@ -115,7 +117,7 @@ export default class ComponentFactory {
 			);
 		}
 
-		return this._components.get( getNormalized( name ) )( this.editor.locale );
+		return this._components.get( getNormalized( name ) ).callback( this.editor.locale );
 	}
 
 	/**

+ 7 - 1
packages/ckeditor5-ui/tests/componentfactory.js

@@ -33,7 +33,7 @@ describe( 'ComponentFactory', () => {
 			factory.add( 'bar', () => {} );
 			factory.add( 'Baz', () => {} );
 
-			expect( Array.from( factory.names() ) ).to.have.members( [ 'foo', 'bar', 'baz' ] );
+			expect( Array.from( factory.names() ) ).to.have.members( [ 'foo', 'bar', 'Baz' ] );
 		} );
 	} );
 
@@ -53,6 +53,12 @@ describe( 'ComponentFactory', () => {
 				factory.add( 'foo', () => {} );
 			} ).to.throw( CKEditorError, /^componentfactory-item-exists/ );
 		} );
+
+		it( 'does not normalize component names', () => {
+			factory.add( 'FoO', () => {} );
+
+			expect( Array.from( factory.names() ) ).to.have.members( [ 'FoO' ] );
+		} );
 	} );
 
 	describe( 'create()', () => {