diff --git a/manipulation.go b/manipulation.go index 407a963..2df68aa 100644 --- a/manipulation.go +++ b/manipulation.go @@ -372,8 +372,8 @@ func (s *Selection) WrapSelection(sel *Selection) *Selection { // It returns the original set of elements. func (s *Selection) WrapHtml(htmlStr string) *Selection { nodesMap := make(map[html.NodeType][]*html.Node) - var parent *html.Node for _, context := range s.Nodes { + var parent *html.Node if context.Parent != nil { parent = context.Parent } else { diff --git a/manipulation_test.go b/manipulation_test.go index 3f7535a..a08d3bd 100644 --- a/manipulation_test.go +++ b/manipulation_test.go @@ -57,19 +57,21 @@ func TestAfterHtml(t *testing.T) { } func TestAfterHtmlContext(t *testing.T) { - doc := loadString(` + doc := loadString(t, `
| Before | -
| Before2 | +