Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow to insert before/after a node to proceed with the reference node is undefined #53

Open
ZzZombo opened this issue Jan 29, 2018 · 0 comments

Comments

@ZzZombo
Copy link

ZzZombo commented Jan 29, 2018

Currently the library won't allow you to insert before/after if the reference node not found in the parent element's node list, including undefined ones. I want to insert a node after a node found by some criteria, like tag name, and if none found, insert before/after first/last child, and if there are no nodes at all, insert it as first child. First two can be easily done with one-liner like $parent.insertAfter($node,$parent.elements(:TAG<item>).tail // $parent.lastChild()), but to fulfill the last you have to check for child nodes and call a whole different method, like insert to actually insert a node, complicating the code quite a bit.

@JJ JJ added the Enhancement label Nov 27, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants