diff --git a/pkg/message/message_element.go b/pkg/message/message_element.go index e3b0bfc..e65ae7f 100644 --- a/pkg/message/message_element.go +++ b/pkg/message/message_element.go @@ -57,6 +57,11 @@ func (e *ChildrenMessageElement) GetChildren() []MessageElement { return e.children } +func (e *ChildrenMessageElement) SetChildren(children []MessageElement) *ChildrenMessageElement { + e.children = children + return e +} + type ExtendAttributes struct { attributes map[string]string } @@ -72,6 +77,14 @@ func (e *ExtendAttributes) AddAttribute(key, value string) *ExtendAttributes { return result } +func (e *ExtendAttributes) DelAttribute(key string) *ExtendAttributes { + if e == nil { + return nil + } + delete(e.attributes, key) + return e +} + func (e *ExtendAttributes) Get(key string) (string, bool) { if e == nil { return "", false diff --git a/pkg/message/message_element_extend.go b/pkg/message/message_element_extend.go index 7394dbc..4d4037e 100644 --- a/pkg/message/message_element_extend.go +++ b/pkg/message/message_element_extend.go @@ -39,7 +39,7 @@ func (e *MessageElementExtend) Parse(n *html.Node) (MessageElement, error) { return result, nil } -func NewMessageElementExtend(tag string, attrs map[string]string, children ...MessageElement) MessageElement { +func NewMessageElementExtend(tag string, attrs map[string]string, children ...MessageElement) *MessageElementExtend { result := &MessageElementExtend{ tag: tag, }