@@ -17,7 +17,7 @@ export abstract class ButtonBase extends Button {
17
17
/**
18
18
* @internal //copied from image common
19
19
*/
20
- protected async _createImageSourceFromSrc ( value : string | ImageSource | ImageAsset ) {
20
+ protected async _createImageSourceFromSrc ( value : string | ImageSource | ImageAsset , asIcon = true ) {
21
21
const originalValue = value ;
22
22
if ( typeof value === 'string' || value instanceof String ) {
23
23
value = value . trim ( ) ;
@@ -29,10 +29,10 @@ export abstract class ButtonBase extends Button {
29
29
let source : ImageSource ;
30
30
const imageLoaded = ( ) => {
31
31
const currentValue = this . src ;
32
- if ( currentValue !== originalValue ) {
32
+ if ( asIcon && currentValue !== originalValue ) {
33
33
return ;
34
34
}
35
- this . imageSource = source ;
35
+ this . setImageSource ( source , asIcon ) ;
36
36
this . isLoading = false ;
37
37
} ;
38
38
@@ -58,19 +58,23 @@ export abstract class ButtonBase extends Button {
58
58
}
59
59
} else if ( value instanceof ImageSource ) {
60
60
// Support binding the imageSource trough the src property
61
- this . imageSource = value ;
61
+ this . setImageSource ( value , asIcon ) ;
62
62
this . isLoading = false ;
63
63
} else if ( value instanceof ImageAsset ) {
64
64
ImageSource . fromAsset ( value ) . then ( ( result ) => {
65
- this . imageSource = result ;
65
+ this . setImageSource ( result , asIcon ) ;
66
66
this . isLoading = false ;
67
67
} ) ;
68
68
} else {
69
69
// native source
70
- this . imageSource = new ImageSource ( value ) ;
70
+ this . setImageSource ( new ImageSource ( value ) , asIcon ) ;
71
71
this . isLoading = false ;
72
72
}
73
73
}
74
+
75
+ setImageSource ( value , asIcon = true ) {
76
+ this . imageSource = value ;
77
+ }
74
78
}
75
79
76
80
export const imageSourceProperty = new Property < ButtonBase , ImageSource > ( { name : 'imageSource' } ) ;
0 commit comments