Skip to content

fix: MoveToFirst returns false when already on the first sibling - #28

Merged
zhengchun merged 1 commit into
antchfx:masterfrom
SashaMIT:fix/move-to-first
Oct 10, 2026
Merged

zhengchun merged 1 commit into
antchfx:masterfrom
SashaMIT:fix/move-to-first

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

NodeNavigator.MoveToFirst returned true when the navigator was already on the first sibling, and it did not move. xmlquery, htmlquery, and the xpath package's own test navigator return false in that case. A caller that keeps calling the method until it returns false never stops.

Moving from a later sibling back to the first one still returns true.

Test plan

  • go test -count=1 ./...
  • TestMoveToFirst failed before the guard (Should be false on the first sibling) and passes with it. The existing navigator tests still pass.

The method returned true without moving. xmlquery and htmlquery return
false in that case, so a caller can tell the navigator did not move.
@zhengchun
zhengchun merged commit a11e36e into antchfx:master Oct 10, 2026
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Thanks for merging this. MoveToFirst stays false when it is already on the first sibling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants