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

Changed type of collection used in "Template" class.

Kamil Piechaczek 8 лет назад
Родитель
Сommit
8288abba02
2 измененных файлов с 19 добавлено и 2 удалено
  1. 1 2
      packages/ckeditor5-ui/src/template.js
  2. 18 0
      packages/ckeditor5-ui/tests/template.js

+ 1 - 2
packages/ckeditor5-ui/src/template.js

@@ -12,7 +12,6 @@
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
-import Collection from '@ckeditor/ckeditor5-utils/src/collection';
 import View from './view';
 import ViewCollection from './viewcollection';
 import cloneDeepWith from '@ckeditor/ckeditor5-utils/src/lib/lodash/cloneDeepWith';
@@ -1081,7 +1080,7 @@ function normalize( def ) {
 			normalizeAttributes( def.attributes );
 		}
 
-		const children = new Collection();
+		const children = new ViewCollection();
 
 		if ( def.children ) {
 			if ( isViewCollection( def.children ) ) {

+ 18 - 0
packages/ckeditor5-ui/tests/template.js

@@ -9,6 +9,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import { default as Template, TemplateToBinding, TemplateIfBinding } from '../src/template';
 import View from '../src/view';
 import ViewCollection from '../src/viewcollection';
+import InputTextView from '../src/inputtext/inputtextview';
 import Model from '../src/model';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
@@ -121,6 +122,23 @@ describe( 'Template', () => {
 			expect( tpl.attributes.a[ 0 ] ).to.equal( 'foo' );
 			expect( tpl.children.get( 0 ).tag ).to.equal( 'span' );
 		} );
+
+		it( 'does not throw when child does not have an "id" property', () => {
+			class DivView extends View {
+				constructor( locale ) {
+					super( locale );
+
+					this.template = new Template( {
+						tag: 'div',
+						children: [
+							new InputTextView( locale )
+						]
+					} );
+				}
+			}
+
+			expect( () => new DivView( {} ) ).to.not.throw( CKEditorError );
+		} );
 	} );
 
 	describe( 'render()', () => {