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

Commit

Permalink
Merge pull request #111 from ckeditor/t/ckeditor5-engine/1207
Browse files Browse the repository at this point in the history
Other: `core.Command` should listen to `model.Document#event:change`.
  • Loading branch information
Piotr Jasiun authored Jan 11, 2018
2 parents fcb0a71 + 153dda6 commit 912570d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class Command {
this.decorate( 'execute' );

// By default every command is refreshed when changes are applied to the model.
this.listenTo( this.editor.model.document, 'changesDone', () => {
this.listenTo( this.editor.model.document, 'change', () => {
this.refresh();
} );

Expand Down Expand Up @@ -99,7 +99,7 @@ export default class Command {
* in this method.
*
* This method is automatically called when
* {@link module:engine/model/document~Document#event:changesDone any changes are applied to the model}.
* {@link module:engine/model/document~Document#event:change any changes are applied to the document}.
*/
refresh() {
this.isEnabled = true;
Expand Down
4 changes: 2 additions & 2 deletions tests/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ describe( 'Command', () => {
expect( command.isEnabled ).to.be.false;
} );

it( 'adds a listener which refreshed the command on editor.model.document#changesDone', () => {
it( 'adds a listener which refreshes the command on editor.model.Document#event:change', () => {
sinon.spy( command, 'refresh' );

editor.model.document.fire( 'changesDone' );
editor.model.document.fire( 'change' );

expect( command.refresh.calledOnce ).to.be.true;
} );
Expand Down

0 comments on commit 912570d

Please sign in to comment.