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

Changed ImageStyleCommand#defaultStyle from private to public readonly property #290

Merged
merged 1 commit into from
May 20, 2019
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
10 changes: 5 additions & 5 deletions src/imagestyle/imagestylecommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export default class ImageStyleCommand extends Command {
super( editor );

/**
* The cached name of the default style if it is present. If there is no default style, it defaults to `false`.
* The name of the default style, if it is present. If there is no default style, it defaults to `false`.
*
* @readonly
* @type {Boolean|String}
* @private
*/
this._defaultStyle = false;
this.defaultStyle = false;

/**
* A style handled by this command.
Expand All @@ -43,7 +43,7 @@ export default class ImageStyleCommand extends Command {
styles[ style.name ] = style;

if ( style.isDefault ) {
this._defaultStyle = style.name;
this.defaultStyle = style.name;
}

return styles;
Expand All @@ -64,7 +64,7 @@ export default class ImageStyleCommand extends Command {
const attributeValue = element.getAttribute( 'imageStyle' );
this.value = this.styles[ attributeValue ] ? attributeValue : false;
} else {
this.value = this._defaultStyle;
this.value = this.defaultStyle;
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/imagestyle/imagestylecommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ describe( 'ImageStyleCommand', () => {
} );
} );

it( 'should have defaultStyle property correctly set', () => {
expect( command.defaultStyle ).to.equal( 'defaultStyle' );
} );

it( 'command value should be false if no image is selected', () => {
setData( model, '[]<image></image>' );

Expand Down