From 5ab9ae9ca373af331b23324a3f604caece4a5681 Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Fri, 8 Jul 2022 00:32:18 +0200 Subject: [PATCH] feat: Add NewTextNode --- html.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/html.go b/html.go index 2320dbf..ef55e5c 100644 --- a/html.go +++ b/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:])