Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

$("tr:eq(2)") won't work but $("tr").eq(2) does #129

Closed
tekny opened this issue Dec 1, 2012 · 7 comments · Fixed by #1565
Closed

$("tr:eq(2)") won't work but $("tr").eq(2) does #129

tekny opened this issue Dec 1, 2012 · 7 comments · Fixed by #1565

Comments

@tekny
Copy link

tekny commented Dec 1, 2012

The problem is :eq, :gt, :lt selectors are not working. They just return empty result.

@fb55
Copy link
Member

fb55 commented Dec 1, 2012

That's because :eq and friends aren't implemented. I'm wondering why you're getting results at all, as using them should throw a SyntaxError.

@reezer
Copy link

reezer commented Dec 30, 2012

Could they be supported? Sizzle does. The same is true for jQuery, etc.

@fb55
Copy link
Member

fb55 commented Dec 31, 2012

CSSselect applies selectors right-to-left, Sizzle left-to-right. RTL
comes with a nice performance benefit, as it's always O(n), while
Sizzle is O(n^m) (m being the level of child selectors).

There are some features that CSSselect therefore can't support, eg.
:eq (as that applies to matches on the left side) and child
selector-first queries.

@ralyodio
Copy link

if you can't support the jQuery api, then don't claim to support it at all.

@fb55
Copy link
Member

fb55 commented May 24, 2014

Cheerio supports jQuery's core API. There are some parts that won't be supported due to practical reasons (animations), the rest is added as needed. Some weird parts won't be supported, unless someone makes a convincing case for them (& pull requests help, too).

@awvalenti
Copy link

Can't cheerio convert $('element:eq(1)') internally to work the same as $('element').eq(1)?

@watson
Copy link

watson commented Oct 14, 2014

@awvalenti I've just build a module that does just that, though it doesn't hook into cheerio but you can use it along side cheerio: https://github.com/watson/cheerio-eq

Currently it only fixes :eq(), but it would be trivial to add support for other selectors (though in that case I would have to rename the module ;)

Let me know what you think and please open pull requests or issues if you have any suggestions/comments/bugs/feedback :)

wataori pushed a commit to wataori/cheerio that referenced this issue Jan 9, 2015
fb55 added a commit that referenced this issue Dec 15, 2020
Adds support for jQuery positional selectors (:eq, :first, :not(:last) etc.).

Fixes #1355
Fixes #129
fb55 added a commit that referenced this issue Dec 20, 2020
Adds support for jQuery positional selectors (:eq, :first, :not(:last) etc.).

Fixes #1355
Fixes #129
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

6 participants