MCPcopy
hub / github.com/PuerkitoBio/goquery / cloneNode

Function cloneNode

manipulation.go:606–620  ·  view source on GitHub ↗

Deep copy a node. The new node has clones of all the original node's children but none of its parents or siblings.

(n *html.Node)

Source from the content-addressed store, hash-verified

604// Deep copy a node. The new node has clones of all the original node's
605// children but none of its parents or siblings.
606func cloneNode(n *html.Node) *html.Node {
607 nn := &html.Node{
608 Type: n.Type,
609 DataAtom: n.DataAtom,
610 Data: n.Data,
611 Attr: make([]html.Attribute, len(n.Attr)),
612 }
613
614 copy(nn.Attr, n.Attr)
615 for c := n.FirstChild; c != nil; c = c.NextSibling {
616 nn.AppendChild(cloneNode(c))
617 }
618
619 return nn
620}
621
622func (s *Selection) manipulateNodes(ns []*html.Node, reverse bool,
623 f func(sn *html.Node, n *html.Node)) *Selection {

Callers 5

WrapAllNodeMethod · 0.85
wrapInnerNodesMethod · 0.85
cloneNodesFunction · 0.85
manipulateNodesMethod · 0.85
CloneDocumentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…