Giter Site home page Giter Site logo

Comments (3)

smileLilith avatar smileLilith commented on May 28, 2024

It seems the behavior was broken in this commit 9170b1d where cssSelectorComponent isn't executed for element of instance Document where previously it was.

cssSelectorComponent contains the line

if (parent() == null || parent() instanceof Document) // don't add Document to selector, as will always have a html node
, however, it's not reachable due to
while (el != null && !(el instanceof Document)) {

@jhy was there any reason behind that?

from jsoup.

jhy avatar jhy commented on May 28, 2024

@jhy was there any reason behind that?

Yes, as noted in the comment if you're getting a selector for an element it is going to descend from html and so it doesn't need the #root selector. And the #root nodename is not really documented, or supported outside of jsoup. I felt it was wrong to be leaking in to the selector.

Can you tell me more about your use case - what do need a Document selector generated from a Document for?

Perhaps we could change the cssSelector method to return #root if it's called on a Document directly, or there's no other contents to the selector.

from jsoup.

jhy avatar jhy commented on May 28, 2024

Also - returning #root is just wrong as it won't match anything - it would look for elements with an ID of root, which won't match.

So I'm confused that you're hitting an issue here; would be great to get some more details.

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.