Explorar el Código

Merge pull request #290 from ckeditor/t/289

Fix: The `Template` class should not throw an error when a child view in the definition has an `id` attribute set without a value. Closes #289.
Aleksander Nowodzinski hace 8 años
padre
commit
d1668eda37
Se han modificado 2 ficheros con 19 adiciones y 2 borrados
  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

@@ -570,6 +570,24 @@ describe( 'Template', () => {
 					'<p><a></a><b></b><i>foo</i></p>'
 				);
 			} );
+
+			// https://github.com/ckeditor/ckeditor5-ui/issues/289
+			it( 'does not throw when child does not have an "id" property', () => {
+				const strongView = getView( {
+					tag: 'strong'
+				} );
+
+				strongView.set( 'id' );
+
+				expect( () => {
+					getView( {
+						tag: 'div',
+						children: [
+							strongView
+						]
+					} );
+				} ).to.not.throw();
+			} );
 		} );
 
 		describe( 'bindings', () => {