Git Product home page Git Product logo

Comments (3)

nolanw avatar nolanw commented on July 17, 2024 1

I think childNodes is a good idea. NSOrderedSet isn't a very common collection so the weirdness with the array property isn't obvious, and I doubt you're the first person to hesitate when looking for an array of child nodes.

I'll keep this issue open while pondering and then probably adding childNodes.

from htmlreader.

nolanw avatar nolanw commented on July 17, 2024

Hello! I’m not sure I understand 100% so forgive me if I'm off base here.

I think you reached for childElementNodes because you needed an NSArray but had an NSOrderedSet. What you ended up doing is exactly right: ask the ordered set for its contents as an array. (Happily this is cheap; if I recall correctly, the array you get back just proxies the ordered set, there’s no copying going on.)

childElementNodes does filter out out non-element nodes such as text nodes, and is tended as a convenience property for that (presumably) common need. Do you find that children does not include text nodes? Because it absolutely should. HTMLTextNode is a subclass of HTMLNode so the declared types don’t indicate any kind of filtering here.

I’m always happy to fix any documentation that’s not doing its job. Once we sort this out I’ll do another pass and see if I can clear things up!

from htmlreader.

Apocryphon avatar Apocryphon commented on July 17, 2024

My main issue with childElementNodes is that it doesn't have a variant that returns text nodes, but I suppose children is a valid substitute for what I'm trying to achieve. I guess I was just expecting there would be something like a childNodes property that would be like childElementNodes except with all nodes, but then it would be a bit redundant when children exists.

from htmlreader.

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.