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

Commit

Permalink
Merge pull request #377 from ckeditor/t/376
Browse files Browse the repository at this point in the history
Other: ComponentFactory.names() will return original component names (instead of normalized names). Closes #376.
  • Loading branch information
jodator authored Mar 9, 2018
2 parents cada5d8 + 9d6d5ce commit b6b39d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/componentfactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand All @@ -87,7 +89,7 @@ export default class ComponentFactory {
);
}

this._components.set( getNormalized( name ), callback );
this._components.set( getNormalized( name ), { callback, originalName: name } );
}

/**
Expand Down Expand Up @@ -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 );
}

/**
Expand Down
8 changes: 7 additions & 1 deletion tests/componentfactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] );
} );
} );

Expand All @@ -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()', () => {
Expand Down

0 comments on commit b6b39d7

Please sign in to comment.