Browse Source

Fixed the document version comparison.

Maciej Bukowski 6 years ago
parent
commit
7e3c3581dc

+ 1 - 3
packages/ckeditor5-watchdog/src/watchdog.js

@@ -310,9 +310,7 @@ export default class Watchdog {
 
 		// Change may not produce an operation, so the document's version
 		// can be the same after that change.
-		if ( version < this._lastDocumentVersion ) {
-			this._throttledSave.cancel();
-
+		if ( version === this._lastDocumentVersion ) {
 			return;
 		}
 

+ 7 - 3
packages/ckeditor5-watchdog/tests/watchdog.js

@@ -601,10 +601,14 @@ describe( 'Watchdog', () => {
 				initialData: '<p>foo</p>',
 				plugins: [ Paragraph ]
 			} ).then( () => {
-				const doc = watchdog.editor.model.document;
+				const model = watchdog.editor.model;
+				const doc = model.document;
 
-				watchdog.editor.model.document.version = -1000;
-				watchdog.editor.model.change( writer => {
+				// Decrement the document version to simulate a situation when an operation
+				// don't produce new document version.
+				doc.version--;
+
+				model.change( writer => {
 					writer.insertText( 'bar', writer.createPositionAt( doc.getRoot(), 1 ) );
 				} );