0
0
mirror of https://github.com/crazy-max/diun.git synced 2024-12-23 03:48:00 +00:00
crazy-max_diun/vendor/github.com/vanng822/go-premailer/premailer/util.go
2024-12-14 22:30:21 +01:00

25 lines
685 B
Go

package premailer
import (
"github.com/vanng822/css"
)
func copyRule(selector string, rule *css.CSSRule) *css.CSSRule {
// copy rule for each selector
styles := make([]*css.CSSStyleDeclaration, 0)
for _, s := range rule.Style.Styles {
styles = append(styles, css.NewCSSStyleDeclaration(s.Property, s.Value, s.Important))
}
copiedStyle := css.CSSStyleRule{SelectorText: selector, Styles: styles}
copiedRule := &css.CSSRule{Type: rule.Type, Style: copiedStyle}
return copiedRule
}
func makeRuleImportant(rule *css.CSSRule) string {
// this for using Text() which has nice sorted props
for _, s := range rule.Style.Styles {
s.Important = 1
}
return rule.Style.Text()
}