You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@parent = old_parent should happen inside an ensure so that it happens even in the event of a raise escaping the block. We would be happy to open a PR with the fix and a few tests if you're interested.
The text was updated successfully, but these errors were encountered:
ric2b
changed the title
[bug] XML::Builder blocks don't restore the parent node when an error is raised inside it
[bug] XML::Builder blocks don't restore the parent node when an error is raised from the block
Nov 17, 2021
@ric2b Thanks for opening this issue! That's certainly odd behavior, and I agree we should change it. I'll try to set aside some time this weekend to dig in a bit.
When using the XML builder, exceptions that escape a node's block will cause that node to become the parent of sibling nodes.
For example, this:
Outputs this (
b
should not be a child ofa
):Expected behavior
b
should be a sibling ofa
:Environment
Additional context
I'm pretty sure the issue is here: https://github.com/sparklemotion/nokogiri/blob/v1.12.5/lib/nokogiri/xml/builder.rb#L422-L438
@parent = old_parent
should happen inside anensure
so that it happens even in the event of araise
escaping the block. We would be happy to open a PR with the fix and a few tests if you're interested.The text was updated successfully, but these errors were encountered: