@@ -17,7 +17,7 @@ export abstract class ButtonBase extends Button {
1717 /**
1818 * @internal //copied from image common
1919 */
20- protected async _createImageSourceFromSrc ( value : string | ImageSource | ImageAsset ) {
20+ protected async _createImageSourceFromSrc ( value : string | ImageSource | ImageAsset , asIcon = true ) {
2121 const originalValue = value ;
2222 if ( typeof value === 'string' || value instanceof String ) {
2323 value = value . trim ( ) ;
@@ -29,10 +29,10 @@ export abstract class ButtonBase extends Button {
2929 let source : ImageSource ;
3030 const imageLoaded = ( ) => {
3131 const currentValue = this . src ;
32- if ( currentValue !== originalValue ) {
32+ if ( asIcon && currentValue !== originalValue ) {
3333 return ;
3434 }
35- this . imageSource = source ;
35+ this . setImageSource ( source , asIcon ) ;
3636 this . isLoading = false ;
3737 } ;
3838
@@ -58,19 +58,23 @@ export abstract class ButtonBase extends Button {
5858 }
5959 } else if ( value instanceof ImageSource ) {
6060 // Support binding the imageSource trough the src property
61- this . imageSource = value ;
61+ this . setImageSource ( value , asIcon ) ;
6262 this . isLoading = false ;
6363 } else if ( value instanceof ImageAsset ) {
6464 ImageSource . fromAsset ( value ) . then ( ( result ) => {
65- this . imageSource = result ;
65+ this . setImageSource ( result , asIcon ) ;
6666 this . isLoading = false ;
6767 } ) ;
6868 } else {
6969 // native source
70- this . imageSource = new ImageSource ( value ) ;
70+ this . setImageSource ( new ImageSource ( value ) , asIcon ) ;
7171 this . isLoading = false ;
7272 }
7373 }
74+
75+ setImageSource ( value , asIcon = true ) {
76+ this . imageSource = value ;
77+ }
7478}
7579
7680export const imageSourceProperty = new Property < ButtonBase , ImageSource > ( { name : 'imageSource' } ) ;
0 commit comments