WrapAllNode wraps the given node around the first element in the Selection, making all other nodes in the Selection children of the given node. The node is cloned before being inserted into the document. It returns the original set of elements.
(n *html.Node)
| 468 | // |
| 469 | // It returns the original set of elements. |
| 470 | func (s *Selection) WrapAllNode(n *html.Node) *Selection { |
| 471 | if s.Size() == 0 { |
| 472 | return s |
| 473 | } |
| 474 | |
| 475 | wrap := cloneNode(n) |
| 476 | |
| 477 | first := s.Nodes[0] |
| 478 | if first.Parent != nil { |
| 479 | first.Parent.InsertBefore(wrap, first) |
| 480 | first.Parent.RemoveChild(first) |
| 481 | } |
| 482 | |
| 483 | for c := getFirstChildEl(wrap); c != nil; c = getFirstChildEl(wrap) { |
| 484 | wrap = c |
| 485 | } |
| 486 | |
| 487 | newSingleSelection(wrap, s.document).AppendSelection(s) |
| 488 | |
| 489 | return s |
| 490 | } |
| 491 | |
| 492 | // WrapInner wraps an HTML structure, matched by the given selector, around the |
| 493 | // content of element in the set of matched elements. The matched child is |
no test coverage detected