8
0
Maciej Bukowski 6 лет назад
Родитель
Сommit
4b90329e7b
2 измененных файлов с 15 добавлено и 17 удалено
  1. 6 5
      packages/ckeditor5-ui/src/template.js
  2. 9 12
      packages/ckeditor5-ui/tests/template.js

+ 6 - 5
packages/ckeditor5-ui/src/template.js

@@ -7,9 +7,9 @@
  * @module ui/template
  */
 
-/* global document, console */
+/* global document */
 
-import CKEditorError, { attachLinkToDocumentation } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
+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 View from './view';
@@ -380,9 +380,10 @@ export default class Template {
 			 *
 			 * @error template-extend-render
 			 */
-			console.warn( attachLinkToDocumentation(
-				'template-extend-render: Attempting to extend a template which has already been rendered.'
-			) );
+			throw new CKEditorError(
+				'template-extend-render: Attempting to extend a template which has already been rendered.',
+				[ this, template ]
+			);
 		}
 
 		extendTemplate( template, normalize( clone( def ) ) );

+ 9 - 12
packages/ckeditor5-ui/tests/template.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-/* globals HTMLElement, Event, document, console */
+/* globals HTMLElement, Event, document */
 
 import { default as Template, TemplateToBinding, TemplateIfBinding } from '../src/template';
 import View from '../src/view';
@@ -2331,9 +2331,7 @@ describe( 'Template', () => {
 			expect( tpl.attributes.b[ 0 ] ).to.equal( 'bar' );
 		} );
 
-		it( 'logs a warning if an element has already been rendered', () => {
-			const consoleWarnStub = sinon.stub( console, 'warn' );
-
+		it( 'throws an error if an element has already been rendered', () => {
 			const tpl = new Template( {
 				tag: 'p'
 			} );
@@ -2346,14 +2344,13 @@ describe( 'Template', () => {
 
 			tpl.render();
 
-			Template.extend( tpl, {
-				attributes: {
-					class: 'bar'
-				}
-			} );
-
-			sinon.assert.calledOnce( consoleWarnStub );
-			sinon.assert.calledWithExactly( consoleWarnStub, sinon.match( /^template-extend-render/ ) );
+			expectToThrowCKEditorError( () => {
+				Template.extend( tpl, {
+					attributes: {
+						class: 'bar'
+					}
+				} );
+			}, /^template-extend-render/ );
 		} );
 
 		describe( 'attributes', () => {