8
0
Просмотр исходного кода

Merge pull request #53 from ckeditor/t/52

t/52: Simplified Controller#addCollection locale management.
Piotrek Koszuliński 9 лет назад
Родитель
Сommit
ad80254d82

+ 2 - 4
packages/ckeditor5-ui/src/controller.js

@@ -156,12 +156,10 @@ export default class Controller {
 	 * Adds a new collection to {@link ui.Controller#collections}.
 	 *
 	 * @param {String} collectionName Name of the controller collection.
-	 * @param {utils.Locale} [locale] The {@link ckeditor5.Editor#locale editor's locale} instance.
-	 * See {@link ui.ControllerCollection#locale}.
 	 * @returns {ui.ControllerCollection} The new collection instance.
 	 */
-	addCollection( collectionName, locale ) {
-		const collection = new ControllerCollection( collectionName, locale );
+	addCollection( collectionName ) {
+		const collection = new ControllerCollection( collectionName, this.view && this.view.locale );
 
 		this.collections.add( collection );
 

+ 2 - 4
packages/ckeditor5-ui/tests/controller.js

@@ -425,12 +425,10 @@ describe( 'Controller', () => {
 		} );
 
 		it( 'should pass locale to controller collection', () => {
-			const controller = new Controller();
 			const locale = {};
+			const view = new View( locale );
 
-			controller.addCollection( 'foo', locale );
-
-			expect( controller.collections.get( 'foo' ).locale ).to.equal( locale );
+			expect( new Controller( {}, view ).addCollection( 'foo' ).locale ).to.equal( locale );
 		} );
 	} );
 } );