jamietre / CsQuery

CsQuery is a complete CSS selector engine, HTML parser, and jQuery port for C# and .NET 4.
Other
1.16k stars 249 forks source link

Support subject selector #120

Open benjamingr opened 11 years ago

benjamingr commented 11 years ago

It would be nice if we could have support for the subject selector.

For example (from the spec):

  !div > !p.warning

Selects add div elements that have a p.warning and all the p.warnings themselves.

jamietre commented 11 years ago

I'd planned to add L4 support sooner rather than later, though when I first read through the spec there were some selectors that did not fit the pattern of all L3 selectors (in terms of the ability to perform left>right evaluation as CsQuery does) and would have required some changes to the engine to support.

This one looks like it could be done easily though, this seems more or less like nicer syntax for the :has jquery extension?

benjamingr commented 11 years ago

That basic example can be created using :has.

Keep in mind, this can get quite complicated: div > !a > b which could be dom["div"].find("a:has(b)"). Generally, I think this is a very nice feature that would let us do interesting queries.