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

Method WrapInnerHtml

manipulation.go:524–535  ·  view source on GitHub ↗

WrapInnerHtml wraps an HTML structure, matched by the given selector, around the content of element in the set of matched elements. The matched child is cloned before being inserted into the document. It returns the original set of elements.

(htmlStr string)

Source from the content-addressed store, hash-verified

522//
523// It returns the original set of elements.
524func (s *Selection) WrapInnerHtml(htmlStr string) *Selection {
525 nodesMap := make(map[string][]*html.Node)
526 for _, context := range s.Nodes {
527 nodes, found := nodesMap[nodeName(context)]
528 if !found {
529 nodes = parseHtmlWithContext(htmlStr, context)
530 nodesMap[nodeName(context)] = nodes
531 }
532 newSingleSelection(context, s.document).wrapInnerNodes(cloneNodes(nodes)...)
533 }
534 return s
535}
536
537// WrapInnerNode wraps an HTML structure, matched by the given selector, around
538// the content of element in the set of matched elements. The matched child is

Callers 1

TestWrapInnerHtmlFunction · 0.80

Calls 5

nodeNameFunction · 0.85
parseHtmlWithContextFunction · 0.85
newSingleSelectionFunction · 0.85
cloneNodesFunction · 0.85
wrapInnerNodesMethod · 0.80

Tested by 1

TestWrapInnerHtmlFunction · 0.64