diff --git a/core/editor.js b/core/editor.js index a77d972b55a..3dfbf8c5d54 100644 --- a/core/editor.js +++ b/core/editor.js @@ -885,10 +885,10 @@ * * editorInstance.execCommand( 'bold' ); * - * @param {String} commandName The indentifier name of the command. - * @param {Object} [data] The data to be passed to the command. - * @returns {Boolean} `true` if the command was executed - * successfully, otherwise `false`. + * @param {String} commandName The identifier name of the command. + * @param {Object} [data] The data to be passed to the command. It defaults to + * an empty object starting from 4.7.0. + * @returns {Boolean} `true` if the command was executed successfully, `false` otherwise. * @see CKEDITOR.editor#addCommand */ execCommand: function( commandName, data ) { @@ -896,7 +896,7 @@ var eventData = { name: commandName, - commandData: data, + commandData: data || {}, command: command }; @@ -1572,7 +1572,7 @@ CKEDITOR.ELEMENT_MODE_INLINE = 3; * @member CKEDITOR.config */ - /** +/** * Customizes the {@link CKEDITOR.editor#title human-readable title} of this editor. This title is displayed in * tooltips and impacts various [accessibility aspects](#!/guide/dev_a11y-section-announcing-the-editor-on-the-page), * e.g. it is commonly used by screen readers for distinguishing editor instances and for navigation. diff --git a/tests/core/command/events.js b/tests/core/command/events.js index 25c624129f1..59fb02836b2 100644 --- a/tests/core/command/events.js +++ b/tests/core/command/events.js @@ -34,6 +34,29 @@ this.editor.execCommand( 'mockupCommand' ); assert.isTrue( cmdCalled, 'Command should be called' ); + }, + + // #17027 + 'test default event data value': function() { + var beforeExecData; + + this.editor.once( 'beforeCommandExec', function( evt ) { + beforeExecData = evt.data.commandData; + + assert.isObject( beforeExecData, 'Event data is initialized as an empty object' ); + } ); + + this.editor.once( 'afterCommandExec', function( evt ) { + assert.areSame( beforeExecData, evt.data.commandData, 'The same object is passed to afterCommandExec' ); + } ); + + this.editor.addCommand( 'dataFlow', { + exec: function( editor, data ) { + assert.areSame( beforeExecData, data, 'Same object is given as data' ); + } + } ); + + this.editor.execCommand( 'dataFlow' ); } } ); -} )(); \ No newline at end of file +} )();