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

core.Command should listen to model.Document#event:change #111

Merged
merged 1 commit into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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