feat: Add NewTextNode

This commit is contained in:
ptrcnull 2022-07-08 00:32:18 +02:00
parent 8b4b2ec3cd
commit 5ab9ae9ca3

10
html.go
View file

@ -28,6 +28,16 @@ func ParseNode(r io.Reader) (*Node, error) {
return &Node{n[0]}, nil
}
func NewTextNode(text string) *Node {
return &Node{
Node: &html.Node{
Type: html.TextNode,
DataAtom: 0x0,
Data: text,
},
}
}
func (n *Node) QuerySelector(selector string) *Node {
if strings.HasPrefix(selector, "#") {
return n.GetElementById(selector[1:])