Skip to content

Commit

Permalink
fix(domtest): add Deprecated DocumentFragment temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
crhntr committed Jun 23, 2024
1 parent 5317d85 commit bbb4471
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions domtest/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ func Reader(t T, r io.Reader) spec.Document {
return dom.NewNode(node).(spec.Document)
}

// DocumentFragment creates a list of elements from a reader.
// It does not skip text nodes and will panic if it encounters any.
// Deprecated: use DocumentFragmentReader instead
func DocumentFragment(t T, r io.Reader, parent atom.Atom) []spec.Element {
t.Helper()
nodes, err := html.ParseFragment(r, &html.Node{
Type: html.ElementNode,
Data: parent.String(),
DataAtom: parent,
})
if err != nil {
t.Error(err)
return nil
}
var result []spec.Element
for _, node := range nodes {
result = append(result, dom.NewNode(node).(spec.Element))
}
return result
}

func DocumentFragmentReader(t T, r io.Reader, parent atom.Atom) spec.DocumentFragment {
t.Helper()

Expand Down

0 comments on commit bbb4471

Please sign in to comment.