feat: Add NewTextNode
This commit is contained in:
parent
8b4b2ec3cd
commit
5ab9ae9ca3
1 changed files with 10 additions and 0 deletions
10
html.go
10
html.go
|
@ -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:])
|
||||
|
|
Loading…
Reference in a new issue