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

Commit d7072ba

Browse files
authored
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.
2 parents 7d01939 + 8b0a5b7 commit d7072ba

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/template.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
1313
import mix from '@ckeditor/ckeditor5-utils/src/mix';
1414
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
15-
import Collection from '@ckeditor/ckeditor5-utils/src/collection';
1615
import View from './view';
1716
import ViewCollection from './viewcollection';
1817
import cloneDeepWith from '@ckeditor/ckeditor5-utils/src/lib/lodash/cloneDeepWith';
@@ -1081,7 +1080,7 @@ function normalize( def ) {
10811080
normalizeAttributes( def.attributes );
10821081
}
10831082

1084-
const children = new Collection();
1083+
const children = new ViewCollection();
10851084

10861085
if ( def.children ) {
10871086
if ( isViewCollection( def.children ) ) {

tests/template.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,24 @@ describe( 'Template', () => {
570570
'<p><a></a><b></b><i>foo</i></p>'
571571
);
572572
} );
573+
574+
// https://github.com/ckeditor/ckeditor5-ui/issues/289
575+
it( 'does not throw when child does not have an "id" property', () => {
576+
const strongView = getView( {
577+
tag: 'strong'
578+
} );
579+
580+
strongView.set( 'id' );
581+
582+
expect( () => {
583+
getView( {
584+
tag: 'div',
585+
children: [
586+
strongView
587+
]
588+
} );
589+
} ).to.not.throw();
590+
} );
573591
} );
574592

575593
describe( 'bindings', () => {

0 commit comments

Comments
 (0)