Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

:eq css selector should index from zero #652

Open
mattheworiordan opened this Issue · 3 comments

2 participants

@mattheworiordan

I read on https://github.com/tenderlove/nokogiri/wiki/From-jQuery-Traversing about using :eq for traversing and selecting an element using Nokogiri, which is great... untilI discovered that :eq(1) refers to the first element with Nokogiri, and in JQuery it refers to the second element (zero indexed), see http://api.jquery.com/eq/. As I interchangeably use my CSS selectors in client-side Javascript tests and Capybara tests, this is causing endless issues.

I propose that :eq should be compatible with JQuery and use an zero based index.

@mattheworiordan

Sorry, I should have added this in for reference, http://stackoverflow.com/questions/4124523/what-library-does-capybara-use-as-css-selector. I have seen a few mentions online of people experiencing the same surprise.

@flavorjones
Owner

See https://github.com/tenderlove/nokogiri/issues/628 for related bug report.

Because this sort of change can break lots of things in bad ways, we're planning on addressing JQuery compatibility in 2.0. You can read more about the roadmap here: https://github.com/tenderlove/nokogiri/blob/master/ROADMAP.md

I'll add this issue to the roadmap.

@mattheworiordan

Thanks for the reply, makes sense to make this part of a bigger update as you're right, it could certainly break things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.