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

Inspection never shows children in a tree, causes errors for other node types #41

Open
JanBliznicenko opened this issue Jan 13, 2025 · 0 comments

Comments

@JanBliznicenko
Copy link
Contributor

JanBliznicenko commented Jan 13, 2025

There are multiple issues caused by b55512b

The condition for isContentNode in XMLNode>>#inspectTreeIn: is reversed, so something that has descendantElements (which is only XMLNodeWithElements) always gets no children in the tree, making the tree always have only 1 level. Inversely, anything else, that cannot have any descendants, like XMLAttribute, tries to get these descendantElements, still resulting in an error that the commit attempted to fix.

The fix only works for XMLString, as it returns true for isContentNode, so it does not try to return children as well.

I believe one of the following can be done:

Option 1:

  • remove isContentNode from XMLString, therefore not considering it a content node anymore (which might not be a correct thing to do, don't know the intended semantics for what is considered a "content node" and reasons why this method exists)
  • swap contents of ifTrue: and ifFalse: blocks in XMLNode>>#inspectTreeIn:

Option 2:

  • introduce another typecheck-like testing method, named for example "canHaveDescendantElements", that would return false for XMLNode, true for XMLNodeWithElements (therefore XMLString would also return false)
  • use this canHaveDescendantElements instead of isContentNode in the condition in XMLNode>>#inspectTreeIn:
  • swap contents of ifTrue: and ifFalse: blocks in XMLNode>>#inspectTreeIn:

Option 3:

  • Create method descendantElements in XMLNode that would return an empty array
  • remove the condition in XMLNode>>#inspectTreeIn: altogether and always get descendantElements
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

1 participant