File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
src/BootstrapBlazor/Components/Button Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
9494
9595 if ( ! string . IsNullOrEmpty ( ImageUrl ) )
9696 {
97- builder . AddContent ( 120 , new MarkupString ( $ "<img alt= \" img \" class= \" { ImageCss } \" src= \" { ImageUrl } \" />" ) ) ;
97+ builder . AddContent ( 120 , AddImage ( ) ) ;
9898 }
9999
100100 if ( ! string . IsNullOrEmpty ( Text ) )
@@ -106,12 +106,25 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
106106 builder . CloseElement ( ) ;
107107 }
108108
109+ private RenderFragment AddImage ( ) => builder =>
110+ {
111+ builder . OpenElement ( 0 , "img" ) ;
112+ builder . AddAttribute ( 10 , "src" , ImageUrl ) ;
113+ builder . AddAttribute ( 20 , "alt" , "img" ) ;
114+ if ( ! string . IsNullOrEmpty ( ImageCss ) )
115+ {
116+ builder . AddAttribute ( 30 , "class" , ImageCss ) ;
117+ }
118+ builder . CloseElement ( ) ;
119+ } ;
120+
109121 private async Task OnClickButton ( )
110122 {
111123 if ( OnClickWithoutRender != null )
112124 {
113125 await OnClickWithoutRender ( ) ;
114126 }
127+
115128 if ( OnClick . HasDelegate )
116129 {
117130 await OnClick . InvokeAsync ( ) ;
You can’t perform that action at this time.
0 commit comments