diff options
author | ale <ale@incal.net> | 2021-07-12 17:29:19 +0000 |
---|---|---|
committer | ale <ale@incal.net> | 2021-07-12 17:29:19 +0000 |
commit | ef2c410063d3be2632ad7449cab6f51511face6b (patch) | |
tree | 9d2e82374a063f3b568110e83ccb1b285f3247f1 /vendor/github.com/PuerkitoBio/goquery/utilities.go | |
parent | 877afafd950b84242204499b3ed8c1b2c8c75f31 (diff) | |
parent | 557f9d889812976293b4a668c190e0e1e0332857 (diff) | |
download | crawl-ef2c410063d3be2632ad7449cab6f51511face6b.tar.gz crawl-ef2c410063d3be2632ad7449cab6f51511face6b.zip |
Merge branch 'renovate/github.com-puerkitobio-goquery-1.x' into 'master'
Update module github.com/PuerkitoBio/goquery to v1.7.1
See merge request ale/crawl!3
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 "" } |