Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit b6b39d7

Browse files
authored
Merge pull request #377 from ckeditor/t/376
Other: ComponentFactory.names() will return original component names (instead of normalized names). Closes #376.
2 parents cada5d8 + 9d6d5ce commit b6b39d7

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/componentfactory.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export default class ComponentFactory {
6262
* @returns {Iterable.<String>}
6363
*/
6464
* names() {
65-
yield* this._components.keys();
65+
for ( const value of this._components.values() ) {
66+
yield value.originalName;
67+
}
6668
}
6769

6870
/**
@@ -87,7 +89,7 @@ export default class ComponentFactory {
8789
);
8890
}
8991

90-
this._components.set( getNormalized( name ), callback );
92+
this._components.set( getNormalized( name ), { callback, originalName: name } );
9193
}
9294

9395
/**
@@ -115,7 +117,7 @@ export default class ComponentFactory {
115117
);
116118
}
117119

118-
return this._components.get( getNormalized( name ) )( this.editor.locale );
120+
return this._components.get( getNormalized( name ) ).callback( this.editor.locale );
119121
}
120122

121123
/**

tests/componentfactory.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe( 'ComponentFactory', () => {
3333
factory.add( 'bar', () => {} );
3434
factory.add( 'Baz', () => {} );
3535

36-
expect( Array.from( factory.names() ) ).to.have.members( [ 'foo', 'bar', 'baz' ] );
36+
expect( Array.from( factory.names() ) ).to.have.members( [ 'foo', 'bar', 'Baz' ] );
3737
} );
3838
} );
3939

@@ -53,6 +53,12 @@ describe( 'ComponentFactory', () => {
5353
factory.add( 'foo', () => {} );
5454
} ).to.throw( CKEditorError, /^componentfactory-item-exists/ );
5555
} );
56+
57+
it( 'does not normalize component names', () => {
58+
factory.add( 'FoO', () => {} );
59+
60+
expect( Array.from( factory.names() ) ).to.have.members( [ 'FoO' ] );
61+
} );
5662
} );
5763

5864
describe( 'create()', () => {

0 commit comments

Comments
 (0)