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() with children selectors #528

Closed
rrivas opened this issue Aug 30, 2011 · 6 comments
Closed

CSS3 :not() with children selectors #528

rrivas opened this issue Aug 30, 2011 · 6 comments

Comments

@rrivas
Copy link

rrivas commented Aug 30, 2011

When I attempt to use nokogiri with doc.css('.r .l:not(.mslg .l)') I receive the error

Nokogiri::CSS::SyntaxError: unexpected ' ' after '#<Nokogiri::CSS::Node:0x007fb4ab5f4940>'

I am simply trying to get urls from a google search page. This is what I'm doing

doc = Nokogiri::HTML(open("http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=Honda+Cerritos+CA"))
doc.css('.r .l:not(.mslg .l)')
@MatmaRex
Copy link

MatmaRex commented Sep 4, 2011

This doesn't appear to be valid CSS. It doesn't work in broswer and doesn't pass the validator.

Here's an equivalent, valid code:

*:not(.mslg) .r .l

Or possibly: (I'm not sure what you want - this is an exact equivalent of what I assume you meant)

*:not(.mslg) .r:not(.mslg) .l

@rrivas rrivas closed this as completed Sep 4, 2011
@rrivas rrivas reopened this Sep 8, 2011
@rrivas
Copy link
Author

rrivas commented Sep 8, 2011

What I am attempting to do is get all of the organic urls on the google page. I am using selector gadget (http://www.selectorgadget.com/) to find an accurate path and it tells me that the path I created is an accurate CSS path.

What I am attempting to get is the items in green (http://i.imgur.com/fQ5Jv.png). It could also be that selector gadgets paths are not working properly. I will try your suggestions.

@flavorjones
Copy link
Member

This is a valid request. Currently the state of our CSS selector parsing is a bit complex, which we're planning on overhauling for the next major release.

@ju1ius
Copy link

ju1ius commented May 13, 2012

.r .l:not(.mslg .l)

This is not valid CSS.
The w3c CSS3 spec allows only one simple_selector inside a :not() functional pseudo-class.
A simple_selector is a selector that does not contain any combinator (descendant nor sibling).
CSS4 might allow a (comma-separated) list of simple selectors, but still no combinator.
So it's a safe bet to say that this selector will be invalid for at least the next 10 years...

@flavorjones
Copy link
Member

My previous comment, "This is a valid request" was not referencing the CSS spec -- it was stating my opinion that there's no technological reason we couldn't support this syntax. We already support some jQuery query syntax.

@flavorjones
Copy link
Member

I'm open to accepting a pull request for this functionality, but am unlikely to do that work myself. Closing.

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

4 participants