diff --git a/src/image/utils.js b/src/image/utils.js index 74547099..56a3d223 100644 --- a/src/image/utils.js +++ b/src/image/utils.js @@ -30,11 +30,7 @@ export function toImageWidget( viewElement, label ) { const imgElement = viewElement.getChild( 0 ); const altText = imgElement.getAttribute( 'alt' ); - if ( altText ) { - label = `${ altText } ${ label }`; - } - - return label; + return altText ? `${ altText } ${ label }` : label; } } diff --git a/tests/image/utils.js b/tests/image/utils.js index 5e5331ce..230fd1a6 100644 --- a/tests/image/utils.js +++ b/tests/image/utils.js @@ -30,6 +30,13 @@ describe( 'image widget utils', () => { image.setAttribute( 'alt', 'foo bar baz' ); expect( getLabel( element ) ).to.equal( 'foo bar baz image widget' ); } ); + + it( 'provided label creator should always return same label', () => { + image.setAttribute( 'alt', 'foo bar baz' ); + + expect( getLabel( element ) ).to.equal( 'foo bar baz image widget' ); + expect( getLabel( element ) ).to.equal( 'foo bar baz image widget' ); + } ); } ); describe( 'isImageWidget()', () => {