8
0
Pārlūkot izejas kodu

Fixed image widget fake selection label duplication.

Szymon Kupś 8 gadi atpakaļ
vecāks
revīzija
3a259cc020

+ 1 - 5
packages/ckeditor5-image/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;
 	}
 }
 

+ 7 - 0
packages/ckeditor5-image/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()', () => {