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

Fixed: ModelConversionDispatcher should not convert changes in graveyard (except of remove).

Szymon Cofalik 9 лет назад
Родитель
Сommit
9751212e00

+ 6 - 0
packages/ckeditor5-engine/src/conversion/modelconversiondispatcher.js

@@ -134,6 +134,12 @@ export default class ModelConversionDispatcher {
 	 * @param {Object} data Additional information about the change.
 	 */
 	convertChange( type, data ) {
+		// Do not convert changes if they happen in graveyard.
+		// Graveyard is a special root that has no view / no other representation and changes done in it should not be converted.
+		if ( type !== 'remove' && data.range && data.range.root.rootName == '$graveyard' ) {
+			return;
+		}
+
 		if ( type == 'insert' || type == 'reinsert' ) {
 			this.convertInsert( data.range );
 		} else if ( type == 'move' ) {

+ 11 - 0
packages/ckeditor5-engine/tests/conversion/modelconversiondispatcher.js

@@ -181,6 +181,17 @@ describe( 'ModelConversionDispatcher', () => {
 
 			expect( dispatcher.fire.called ).to.be.false;
 		} );
+
+		it( 'should not fire any event if change was in graveyard root and change type is different than remove', () => {
+			sinon.spy( dispatcher, 'fire' );
+
+			let gyNode = new ModelElement( 'image' );
+			doc.graveyard.appendChildren( gyNode );
+
+			doc.batch().setAttr( 'key', 'value', gyNode );
+
+			expect( dispatcher.fire.called ).to.be.false;
+		} );
 	} );
 
 	describe( 'convertInsert', () => {