Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

CSS3 not selector #205

Closed
mattheworiordan opened this issue Jan 5, 2010 · 4 comments
Closed

CSS3 not selector #205

mattheworiordan opened this issue Jan 5, 2010 · 4 comments

Comments

@mattheworiordan
Copy link

I am trying to use the :not() selector of CSS3 to filter out the first list item from an unordered list.

When I run this code however, I run into an error "RuntimeError: xmlXPathCompOpEval: function first-child not found"

d = Nokogiri::HTML.parse('<html><body><ul><li id="1">1</li><li id="2">2</li><li id="3"<3</li></ul></body></html>')
d.css('ul li:not(:first-child)')

I have tried changing the CSS selector as follows, and got some strange results:

d.css('ul li:not(#2)') # works
d.css('ul li:not(li)') # fails with error Nokogiri::CSS::SyntaxError: unexpected 'li' after ':not('
d.css('ul li:not(:last-child)') # fails with the same original error of function last-child not found
I believe that according to the spec at http://www.w3.org/TR/css3-selectors/#pseudo-classes, these CSS3 selectors should work?

Any help would be appreciated.

Matt

@tenderlove
Copy link
Member

Yes, this looks like a bug. :-(

I believe the CSS parser is accepting this string, but translating it to the wrong XPath. I will investigate

@tenderlove
Copy link
Member

Updating with the CSS spec reference:

http://www.w3.org/TR/css3-selectors/#negation

@thumblemonks
Copy link

I'm having this problem as well. Would be swell if it were fixed :) Doesn't seem like there is a function to support "not".

@tenderlove
Copy link
Member

fixing psuedo selectors and element selectors inside a not() function. closed by 746d086

This issue was closed.
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

No branches or pull requests

2 participants