File tree 2 files changed +7
-7
lines changed
2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -24,15 +24,15 @@ func (n *Node) Ancestors() iter.Seq[*Node] {
24
24
}
25
25
}
26
26
27
- // Children returns an iterator over the immediate children of n,
27
+ // ChildNodes returns an iterator over the immediate children of n,
28
28
// starting with n.FirstChild.
29
29
//
30
30
// Example:
31
31
//
32
- // for child := range n.Children () { ... }
32
+ // for child := range n.ChildNodes () { ... }
33
33
//
34
34
// Mutating a Node or its children while iterating may have unexpected results.
35
- func (n * Node ) Children () iter.Seq [* Node ] {
35
+ func (n * Node ) ChildNodes () iter.Seq [* Node ] {
36
36
_ = n .FirstChild // eager nil check
37
37
38
38
return func (yield func (* Node ) bool ) {
@@ -59,7 +59,7 @@ func (n *Node) Descendants() iter.Seq[*Node] {
59
59
}
60
60
61
61
func (n * Node ) descendants (yield func (* Node ) bool ) bool {
62
- for c := range n .Children () {
62
+ for c := range n .ChildNodes () {
63
63
if ! yield (c ) || ! c .descendants (yield ) {
64
64
return false
65
65
}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import (
11
11
"testing"
12
12
)
13
13
14
- func TestNode_Children (t * testing.T ) {
14
+ func TestNode_ChildNodes (t * testing.T ) {
15
15
tests := []struct {
16
16
in string
17
17
want string
@@ -32,11 +32,11 @@ func TestNode_Children(t *testing.T) {
32
32
// Drill to <html><head></head><body>
33
33
n := doc .FirstChild .FirstChild .NextSibling
34
34
var results []string
35
- for c := range n .Children () {
35
+ for c := range n .ChildNodes () {
36
36
results = append (results , c .Data )
37
37
}
38
38
if got := strings .Join (results , " " ); got != test .want {
39
- t .Errorf ("unexpected children yielded by Children ; want: %q got: %q" , test .want , got )
39
+ t .Errorf ("unexpected children yielded by ChildNodes ; want: %q got: %q" , test .want , got )
40
40
}
41
41
}
42
42
}
You can’t perform that action at this time.
0 commit comments