diff options
author | renovate <renovate-bot@autistici.org> | 2021-07-11 14:26:26 +0000 |
---|---|---|
committer | renovate <renovate-bot@autistici.org> | 2021-07-11 14:26:26 +0000 |
commit | 557f9d889812976293b4a668c190e0e1e0332857 (patch) | |
tree | 9d2e82374a063f3b568110e83ccb1b285f3247f1 /vendor/github.com/PuerkitoBio/goquery/utilities.go | |
parent | 877afafd950b84242204499b3ed8c1b2c8c75f31 (diff) | |
download | crawl-557f9d889812976293b4a668c190e0e1e0332857.tar.gz crawl-557f9d889812976293b4a668c190e0e1e0332857.zip |
Update module github.com/PuerkitoBio/goquery to v1.7.1
Diffstat (limited to 'vendor/github.com/PuerkitoBio/goquery/utilities.go')
-rw-r--r-- | vendor/github.com/PuerkitoBio/goquery/utilities.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/vendor/github.com/PuerkitoBio/goquery/utilities.go b/vendor/github.com/PuerkitoBio/goquery/utilities.go index b4c061a..3e11b1d 100644 --- a/vendor/github.com/PuerkitoBio/goquery/utilities.go +++ b/vendor/github.com/PuerkitoBio/goquery/utilities.go @@ -36,12 +36,22 @@ func NodeName(s *Selection) string { if s.Length() == 0 { return "" } - switch n := s.Get(0); n.Type { + return nodeName(s.Get(0)) +} + +// nodeName returns the node name of the given html node. +// See NodeName for additional details on behaviour. +func nodeName(node *html.Node) string { + if node == nil { + return "" + } + + switch node.Type { case html.ElementNode, html.DoctypeNode: - return n.Data + return node.Data default: - if n.Type >= 0 && int(n.Type) < len(nodeNames) { - return nodeNames[n.Type] + if node.Type >= 0 && int(node.Type) < len(nodeNames) { + return nodeNames[node.Type] } return "" } |