Skip to content

Fix negative nth selector boundary - #240

Merged
Vinyzu merged 1 commit into
mainfrom
fix-negative-nth-boundary
Sep 2, 2026
Merged

Fix negative nth selector boundary#240
Vinyzu merged 1 commit into
mainfrom
fix-negative-nth-boundary

Conversation

@Vinyzu

@Vinyzu Vinyzu commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #239

Copilot AI lite review requested due to automatic review settings September 2, 2026 20:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is a minimal, well-scoped boundary fix that directly addresses the reported off-by-one error without altering unrelated logic.

Pull request overview

Fixes an off-by-one boundary condition in Patchright’s nth() locator handling so negative indices like .last / nth(-1) (and more generally nth(-N)) resolve correctly when the matched element count equals N, aligning .count() behavior with other locator operations.

Changes:

  • Adjusted the negative nth range check in _customFindElementsByParsed to treat -length as a valid index (instead of incorrectly out-of-range).
  • Preserves existing behavior for positive indices and truly out-of-range negative indices.
File summaries
File Description
driver_patches/framesPatch.ts Fixes negative nth() boundary check so nth(-length) is considered valid, preventing .count() from returning 0 for .last on a single match.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Vinyzu
Vinyzu merged commit 220f7aa into main Sep 2, 2026
2 of 3 checks passed
@Vinyzu
Vinyzu deleted the fix-negative-nth-boundary branch September 2, 2026 21:27
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.

[Bug]: Negative nth index off-by-one in _customFindElementsByParsed causes .last.count() to return 0

2 participants