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

Add ParentNode and fix children implementation #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davispuh
Copy link

Look at https://developer.mozilla.org/en-US/docs/Web/API/ParentNode

ParentNode.children returns only element nodes without text nodes unlike Node.childNodes which includes all Nodes and so current implementation is wrong.

Note that I haven't really tested this yet but I think it should work, also there aren't tests for this.

@@ -190,11 +190,6 @@ def remove
parent.remove_child(self) if parent
end

# Remove all the children of the node.
def clear
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this removed on purpose? I still want that available.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it because I wasn't sure if it will work as children is read-only, but seems individual elements can still be removed. Also previously it would remove all child nodes, but now this would remove only element nodes. What is expected behavior?

hmdne added a commit to hmdne/opal-browser that referenced this pull request Jul 5, 2020
@hmdne
Copy link
Member

hmdne commented Jul 5, 2020

Regarding the children method, I think this implementation should follow Nokogiri for an expected behaviour.

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

Successfully merging this pull request may close these issues.

3 participants