Skip to content

Commit d99de58

Browse files
committed
Feedback
1 parent bb50757 commit d99de58

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

html/iter.go

+1-13
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import "iter"
1010

1111
// Ancestors returns an iterator over the ancestors of n, starting with n.Parent.
1212
//
13-
// Example:
14-
//
15-
// for ancestor := range n.Ancestors() { ... }
16-
//
1713
// Mutating a Node or its parents while iterating may have unexpected results.
1814
func (n *Node) Ancestors() iter.Seq[*Node] {
1915
_ = n.Parent // eager nil check
@@ -27,10 +23,6 @@ func (n *Node) Ancestors() iter.Seq[*Node] {
2723
// ChildNodes returns an iterator over the immediate children of n,
2824
// starting with n.FirstChild.
2925
//
30-
// Example:
31-
//
32-
// for child := range n.ChildNodes() { ... }
33-
//
3426
// Mutating a Node or its children while iterating may have unexpected results.
3527
func (n *Node) ChildNodes() iter.Seq[*Node] {
3628
_ = n.FirstChild // eager nil check
@@ -45,16 +37,12 @@ func (n *Node) ChildNodes() iter.Seq[*Node] {
4537
// Descendants returns an iterator over all nodes recursively beneath
4638
// n, excluding n itself. Nodes are visited in depth-first preorder.
4739
//
48-
// Example:
49-
//
50-
// for desc := range n.Descendants() { ... }
51-
//
5240
// Mutating a Node or its descendants while iterating may have unexpected results.
5341
func (n *Node) Descendants() iter.Seq[*Node] {
5442
_ = n.FirstChild // eager nil check
5543

5644
return func(yield func(*Node) bool) {
57-
_ = n.descendants(yield)
45+
n.descendants(yield)
5846
}
5947
}
6048

html/iter_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestNode_ChildNodes(t *testing.T) {
3636
results = append(results, c.Data)
3737
}
3838
if got := strings.Join(results, " "); got != test.want {
39-
t.Errorf("unexpected children yielded by ChildNodes; want: %q got: %q", test.want, got)
39+
t.Errorf("ChildNodes = %q, want %q", got, test.want)
4040
}
4141
}
4242
}
@@ -67,8 +67,7 @@ func TestNode_Descendants(t *testing.T) {
6767
results = append(results, c.Data)
6868
}
6969
if got := strings.Join(results, " "); got != test.want {
70-
t.Errorf("unexpected children yielded by Descendants; want: %q got: %q",
71-
test.want, got)
70+
t.Errorf("Descendants = %q; want: %q", got, test.want)
7271
}
7372
}
7473
}
@@ -81,7 +80,7 @@ func TestNode_Ancestors(t *testing.T) {
8180
nParents++
8281
}
8382
if nParents != size {
84-
t.Errorf("unexpected number of Ancestors; want %d got: %d", size, nParents)
83+
t.Errorf("number of Ancestors = %d; want: %d", nParents, size)
8584
}
8685
}
8786
}

0 commit comments

Comments
 (0)