Bug fixing

This commit is contained in:
Alexei Anoshenko 2024-11-21 17:50:58 +02:00
parent 84a00af595
commit e8da32fca8
1 changed files with 13 additions and 2 deletions

View File

@ -109,8 +109,9 @@ func split4Values(text string) []string {
} }
func backgroundCSS(properties Properties, session Session) string { func backgroundCSS(properties Properties, session Session) string {
if value := properties.getRaw(Background); value != nil { if value := properties.getRaw(Background); value != nil {
if backgrounds, ok := value.([]BackgroundElement); ok { if backgrounds, ok := value.([]BackgroundElement); ok && len(backgrounds) > 0 {
buffer := allocStringBuilder() buffer := allocStringBuilder()
defer freeStringBuilder(buffer) defer freeStringBuilder(buffer)
@ -124,6 +125,11 @@ func backgroundCSS(properties Properties, session Session) string {
} }
if buffer.Len() > 0 { if buffer.Len() > 0 {
backgroundColor, _ := colorProperty(properties, BackgroundColor, session)
if backgroundColor != 0 {
buffer.WriteRune(' ')
buffer.WriteString(backgroundColor.cssString())
}
return buffer.String() return buffer.String()
} }
} }
@ -199,7 +205,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
cssTag string cssTag string
} }
colorProperties := []propertyCss{ colorProperties := []propertyCss{
{BackgroundColor, string(BackgroundColor)}, //{BackgroundColor, string(BackgroundColor)},
{TextColor, "color"}, {TextColor, "color"},
{TextLineColor, "text-decoration-color"}, {TextLineColor, "text-decoration-color"},
{CaretColor, string(CaretColor)}, {CaretColor, string(CaretColor)},
@ -217,6 +223,11 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) {
if background := backgroundCSS(style, session); background != "" { if background := backgroundCSS(style, session); background != "" {
builder.add("background", background) builder.add("background", background)
} else {
backgroundColor, _ := colorProperty(style, BackgroundColor, session)
if backgroundColor != 0 {
builder.add("background-color", backgroundColor.cssString())
}
} }
if font, ok := stringProperty(style, FontName, session); ok && font != "" { if font, ok := stringProperty(style, FontName, session); ok && font != "" {