Git Product home page Git Product logo

Comments (5)

jhy avatar jhy commented on August 21, 2024

Thanks, that looks like a good idea.

It's kind of odd that there's not a native CSS selector syntax to find parents based on their children.

Might also be good to implement jquery's :has() pseudo-selector. So you can do doc.select("p:has(b)") and get the same set as using your parents example.

from jsoup.

svivian avatar svivian commented on August 21, 2024

Heh, well I guess you'll end up implementing all of jQuery's selection and traversing methods at some point ;)

As for CSS, I read an article once on that subject of "parent selectors", the supposed reason being that it's really hard for browsers to implement (or implement efficiently, at least).

from jsoup.

svivian avatar svivian commented on August 21, 2024

Just to clarify if it wasn't clear: in jQuery, parents selects all ancestors of an element matching the optional filter. So if you have nested divs it would fetch all of them (obviously you can just select the first one if necessary with other functions).

I don't know what your approach is with regard to the functions acting on Element vs those on Elements, if you mirror all functions etc.

from jsoup.

jhy avatar jhy commented on August 21, 2024

Thanks. I would look to mirror most functions from Element into Elements where it makes sense -- in this case it would be the combined set of all parents.

from jsoup.

jhy avatar jhy commented on August 21, 2024

Added :has(selector) pseudo-selector.
Added Element#parents() and Elements#parents() methods.

Closed by 49f0e41

from jsoup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.