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

Updated Headings feature with improved event delegation mechanism (EmitterMixin#delegate).

Aleksander Nowodzinski 9 лет назад
Родитель
Сommit
7249804e57

+ 2 - 2
packages/ckeditor5-heading/src/headings.js

@@ -60,8 +60,8 @@ export default class Headings extends Feature {
 		dropdownModel.bind( 'label' ).to( command, 'value', format => format.label );
 
 		// Execute command when an item from the dropdown is selected.
-		this.listenTo( dropdownModel, 'execute', ( dropdownModelEvt, listModelEvt, { source: { id } } ) => {
-			editor.execute( 'headings', id );
+		this.listenTo( dropdownModel, 'execute', ( evt ) => {
+			editor.execute( 'headings', evt.source.id );
 			editor.editing.view.focus();
 		} );
 

+ 4 - 3
packages/ckeditor5-heading/tests/headings.js

@@ -51,10 +51,11 @@ describe( 'Headings', () => {
 		const controller = editor.ui.featureComponents.create( 'headings' );
 		const model = controller.model;
 
-		model.fire( 'execute', {}, { source: { id: 'paragraph', label: 'Paragraph' } } );
+		model.id = 'foo';
+		model.fire( 'execute' );
 
 		sinon.assert.calledOnce( executeSpy );
-		sinon.assert.calledWithExactly( executeSpy, 'headings', 'paragraph' );
+		sinon.assert.calledWithExactly( executeSpy, 'headings', 'foo' );
 	} );
 
 	it( 'should focus view after command execution', () => {
@@ -62,7 +63,7 @@ describe( 'Headings', () => {
 		const controller = editor.ui.featureComponents.create( 'headings' );
 		const model = controller.model;
 
-		model.fire( 'execute', {}, { source: { id: 'paragraph', label: 'Paragraph' } } );
+		model.fire( 'execute' );
 
 		sinon.assert.calledOnce( focusSpy );
 	} );