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

Commit

Permalink
Internal: Removed Model#event:_change.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Mar 15, 2019
1 parent 3706324 commit f36bc26
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 44 deletions.
3 changes: 0 additions & 3 deletions src/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,6 @@ export default class Model {
const callbackReturnValue = this._pendingChanges[ 0 ].callback( this._currentWriter );
ret.push( callbackReturnValue );

// Fire '_change' event before resetting differ.
this.fire( '_change', this._currentWriter );

this.document._handleChangeBlock( this._currentWriter );

this._pendingChanges.shift();
Expand Down
72 changes: 31 additions & 41 deletions tests/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,95 +206,85 @@ describe( 'Model', () => {
} );

it( 'should be possible to nest enqueueChange in enqueueChange event', () => {
model.once( '_change', () => {
changes += 'B';
} );

model.enqueueChange( () => {
changes += 'A';

model.enqueueChange( () => {
changes += 'C';
} );

changes += 'A';
changes += 'B';
} );

expect( changes ).to.equal( 'ABC' );
} );

it( 'should be possible to nest enqueueChange in changes event', () => {
model.once( '_change', () => {
changes += 'B';
} );

model.change( () => {
changes += 'A';

model.enqueueChange( () => {
changes += 'C';
} );

changes += 'A';
changes += 'B';
} );

expect( changes ).to.equal( 'ABC' );
} );

it( 'should be possible to nest changes in enqueueChange event', () => {
model.once( '_change', () => {
changes += 'C';
} );

model.enqueueChange( () => {
changes += 'A';

model.change( () => {
changes += 'A';
changes += 'B';
} );

changes += 'B';
changes += 'C';
} );

expect( changes ).to.equal( 'ABC' );
} );

it( 'should be possible to nest changes in changes event', () => {
model.once( '_change', () => {
changes += 'C';
} );

model.change( () => {
changes += 'A';

model.change( () => {
changes += 'A';
changes += 'B';
} );

changes += 'B';
changes += 'C';
} );

expect( changes ).to.equal( 'ABC' );
} );

it( 'should let mix blocks', () => {
model.once( '_change', () => {
model.change( () => {
changes += 'B';

nestedEnqueue();
} );
model.change( () => {
changes += 'A';

model.change( () => {
model.enqueueChange( () => {
changes += 'C';
} );

changes += 'D';
} );
model.change( () => {
changes += 'D';

model.change( () => {
changes += 'A';
} );

expect( changes ).to.equal( 'ABCDE' );
model.enqueueChange( () => {
changes += 'F';
} );
} );

function nestedEnqueue() {
model.enqueueChange( () => {
changes += 'E';
model.change( () => {
changes += 'E';
} );
} );
}

changes += 'B';
} );

expect( changes ).to.equal( 'ABCDEF' );
} );

it( 'should use the same writer in all change blocks (change & change)', () => {
Expand Down

0 comments on commit f36bc26

Please sign in to comment.