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

Added: RenameDelta throws error when not Element passed.

Szymon Cofalik 9 лет назад
Родитель
Сommit
bd9217ea5a
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      packages/ckeditor5-engine/src/model/delta/renamedelta.js

+ 10 - 0
packages/ckeditor5-engine/src/model/delta/renamedelta.js

@@ -13,6 +13,7 @@ import RemoveOperation from '../operation/removeoperation.js';
 import MoveOperation from '../operation/moveoperation.js';
 import Element from '../element.js';
 import Position from '../position.js';
+import CKEditorError from '../../../utils/ckeditorerror.js';
 
 /**
  * To provide specific OT behavior and better collisions solving, the {@link engine.model.Batch#rename Batch#rename} method
@@ -50,6 +51,15 @@ function apply( batch, delta, operation ) {
  * @param {engine.model.Element} element The element to rename.
  */
 register( 'rename', function( newName, element ) {
+	if ( !( element instanceof Element ) ) {
+		/**
+		 * Trying to rename an object which is not an instance of Element.
+		 *
+		 * @error batch-rename-not-element-instance
+		 */
+		throw new CKEditorError( 'batch-rename-not-element-instance: Trying to rename an object which is not an instance of Element.' );
+	}
+
 	const delta = new RenameDelta();
 	this.addDelta( delta );