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

Commit

Permalink
Fixed image widget fake selection label duplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonkups committed Mar 3, 2017
1 parent d156378 commit 5e752d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/image/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
7 changes: 7 additions & 0 deletions tests/image/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()', () => {
Expand Down

0 comments on commit 5e752d2

Please sign in to comment.