8
0
Просмотр исходного кода

Fix: UnlinkCommand should update its state upon editor load. Closes #93.

Aleksander Nowodzinski 8 лет назад
Родитель
Сommit
911822f48c

+ 3 - 1
packages/ckeditor5-link/src/unlinkcommand.js

@@ -24,7 +24,9 @@ export default class UnlinkCommand extends Command {
 		super( editor );
 
 		// Checks when command should be enabled or disabled.
-		this.listenTo( editor.document.selection, 'change:attribute', () => this.refreshState() );
+		this.listenTo( editor.document, 'changesDone', () => {
+			this.refreshState();
+		} );
 	}
 
 	/**

+ 2 - 2
packages/ckeditor5-link/tests/unlinkcommand.js

@@ -34,10 +34,10 @@ describe( 'UnlinkCommand', () => {
 	} );
 
 	describe( 'constructor()', () => {
-		it( 'should listen on selection attribute change and refresh state', () => {
+		it( 'should listen on document#changesDone and refresh the state', () => {
 			const refreshStateSpy = testUtils.sinon.spy( command, 'refreshState' );
 
-			document.selection.fire( 'change:attribute' );
+			document.fire( 'changesDone' );
 
 			expect( refreshStateSpy.calledOnce ).to.true;
 		} );