Ver código fonte

Mark MarkerOperation as document operation when there is no range to remove.

Oskar Wróbel 8 anos atrás
pai
commit
2971a99700

+ 9 - 2
packages/ckeditor5-engine/src/model/operation/markeroperation.js

@@ -68,9 +68,16 @@ export default class MarkerOperation extends Operation {
 	 * @inheritDoc
 	 */
 	get isDocumentOperation() {
-		const root = this.newRange ? this.newRange.root : this.oldRange.root;
+		if ( this.newRange ) {
+			return !!this.newRange.root.document;
+		}
 
-		return !!root.document;
+		if ( this.oldRange ) {
+			return !!this.oldRange.root.document;
+		}
+
+		// This is edge and might happen only on data from the server.
+		return true;
 	}
 
 	/**

+ 6 - 0
packages/ckeditor5-engine/tests/model/operation/markeroperation.js

@@ -173,6 +173,12 @@ describe( 'MarkerOperation', () => {
 
 			expect( op.isDocumentOperation ).to.true;
 		} );
+
+		it( 'should return true when non-existing marker range is removed from the document', () => {
+			const op = new MarkerOperation( 'name', null, null, doc.markers, doc.version );
+
+			expect( op.isDocumentOperation ).to.true;
+		} );
 	} );
 
 	describe( 'toJSON', () => {