Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Changed: model.Document#getAppliedDeltas should return empty string…
Browse files Browse the repository at this point in the history
… if no deltas were applied.
  • Loading branch information
scofalik committed Apr 4, 2017
1 parent e0145f2 commit dd3015b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/dev-utils/enableenginedebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,16 +462,21 @@ function enableReplayerTools() {
ModelDocument.prototype.applyOperation = function( operation ) {
if ( !this._lastDelta ) {
this._appliedDeltas = [];
this._lastDelta = operation.delta;
} else if ( this._lastDelta !== operation.delta ) {
this._appliedDeltas.push( this._lastDelta.toJSON() );
this._lastDelta = operation.delta;
}

this._lastDelta = operation.delta;

_modelDocumentApplyOperation.call( this, operation );
};

ModelDocument.prototype.getAppliedDeltas = function() {
// No deltas has been applied yet, return empty string.
if ( !this._lastDelta ) {
return '';
}

const appliedDeltas = this._appliedDeltas.concat( this._lastDelta.toJSON() );

return appliedDeltas.map( JSON.stringify ).join( LOG_SEPARATOR );
Expand Down
2 changes: 2 additions & 0 deletions tests/dev-utils/enableenginedebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ describe( 'debug tools', () => {
it( 'getAppliedDeltas()', () => {
const modelDoc = new ModelDocument();

expect( modelDoc.getAppliedDeltas() ).to.equal( '' );

const otherRoot = modelDoc.createRoot( '$root', 'otherRoot' );
const firstEle = new ModelElement( 'paragraph' );
const removedEle = new ModelElement( 'paragraph', null, [ new ModelText( 'foo' ) ] );
Expand Down

0 comments on commit dd3015b

Please sign in to comment.