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

Node.child should be named Node.first_child ? #100

Open
mpage38 opened this issue Oct 5, 2023 · 2 comments
Open

Node.child should be named Node.first_child ? #100

mpage38 opened this issue Oct 5, 2023 · 2 comments

Comments

@mpage38
Copy link

mpage38 commented Oct 5, 2023

I think Node.child should be named Node.first_child, as the access to the last child is named Node.last_child.
BTW, I am surprised that there is no children property.

@rushter
Copy link
Owner

rushter commented Oct 10, 2023

We have .iter(). Does it do what you would expect?

@LeDilam
Copy link

LeDilam commented May 12, 2024

I agree about Node.child to be renamed in Node.first_child because I haven't seen any Node.childs or Node.children so I was expecting Node.child to do that. But it doesn't, it's only the first child and sometime the first child even doesn't work.
I was not expecting Node.iter() to act like what would be a Node.children. I was expecting Node.iter() to "Iterate over nodes on the current level" (what is written in the documentation) meaning I was expecting it to iterate over the rest of nodes that are on the same level than the node I am on, not children of the node.
Because of that I have tried to do Node.child.iter() to iterate over children and it was my last best guess until I found this report.

I think that :

  • the current behavior of Node.iter() should become a Node.children() (and say in the documentation that it "iterate over children of the current node", not saying Iterate "on the current level").
  • Node.child should be renamed Node.first_child and say that it "Return the first child node" instead of "Return the child node"
  • and bugs with using the two dedicated function instead of .iter() needs to be fixed : getting the first child and last child seems buggy when using those function when those child are in a separated line in the html than the start or end of the current node (see issue 114).

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

3 participants