fix: XML::Node#replace returns all nodes reparented #3568
+4
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem is this PR intended to solve?
Fixes #3567 — tested as fixing the spec included therein.
edit: additionally, I can confirm this change fixes the oddity I encountered that led to this discovery.
I found this comment a bit odd in some code I've recently taken responsibility for: https://gitlab.com/gitlab-org/gitlab/-/blob/104b5aa2ea324e3682e8024566daa53bcd45035a/lib/banzai/filter/references/reference_filter.rb#L272-286
Aren't re-parented nodes the same as the actual replaced nodes? I tried adjusting the code to use the return value of
#replaceand remove all that manual tracking, and sure enough, some specs (which test functionality that relies on the replaced nodes being tracked correctly) started to fail. Those specs pass again with this PR being used.Have you included adequate test coverage?
Not yet — I want to confirm that this change looks OK first before doing so. If you're happy, I'll add specs to the PR before marking as ready.
Does this change affect the behavior of either the C or the Java implementations?
What a wonderful question — I have no idea! I'll look into this along with the specs if this looks OK.