Skip to content

Preserve the selection stack for out-of-range Eq calls - #621

Merged
mna merged 1 commit into
PuerkitoBio:masterfrom
yuefdev:fix/eq-empty-selection-stack
Oct 21, 2026
Merged

mna merged 1 commit into
PuerkitoBio:masterfrom
yuefdev:fix/eq-empty-selection-stack

Conversation

@yuefdev

@yuefdev yuefdev commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

sel.Eq(999).End() loses the original selection because the out-of-range branch creates an empty selection without a previous-selection link. AddBack() also returns nothing, even when sel contains nodes.

Use pushStack(s, nil) for that branch, matching other filtering methods. Tests cover positive and negative out-of-range indices on both populated and empty selections. They fail before the fix and check that Eq stays empty while End and AddBack restore the previous selection.

go test ./... -count=1, go vet ./... and gofmt pass.

Signed-off-by: Yusuf Efe <120668197+yuefdev@users.noreply.github.com>
@mna

mna commented Oct 21, 2026

Copy link
Copy Markdown
Member

Thanks, LGTM.

@mna
mna merged commit e265bec into PuerkitoBio:master Oct 21, 2026
6 checks passed
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