-
-
Notifications
You must be signed in to change notification settings - Fork 897
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
Adding namespace-less node to namespaced parent attaches the parent namespace to the child #425
Comments
Confirmed. This is probably a bug. Test to reproduce:
@tenderlove - do you agree that this is unintended behavior? |
I think someone wanted the current behavior. IIRC, we have tests that ensure this behavior. But it could be that those tests were only in the context of the XML builder. When you're hand building a tree like this, I agree, it shouldn't inherit namespaces like that. |
We actually only have tests around adding children of nodes with a
|
I guess we need a way of having this inheritance of namespaces configurable. Is this issue resolved? Is there any by-pass for achieving this? |
Hi. Is this resolved? |
This does not seem to be resolved, I'm on version |
What a surprising and annoying feature. I would have expected |
FYI: My downstream gem broke because of a now missing namespace and I stumbled on this old issue because with the upgrade to version |
Newer versions of Nokogiri (>= 1.12.0) can use libxml >= 2.9.12 which breaks the automatic addition of the parent namespace when adding a child. This was already the case for JRuby, so added the same workaround for when nokogiri is using this newer version of libxml. Ref: sparklemotion/nokogiri#425
@jdongelmans Thanks for the note. I'd like to clarify, though: 889ee2a noted a change in the HTML parser, but this issue is about XML parser behavior. That said, this behavior has also changed in the XML parser (for some of the cases described), and I had a mental note to circle back to this issue to verify that and note it here. I think the behavior changed in #2230 (specifically 1f483f0) but will verify that. Also see related #1712 fixed by that commit. This was noted in the CHANGELOG for v1.12.0 as well. |
@flavorjones Thanks for the clarification. Indeed, you are right. I shortcutted my own thinking because of an already present comment in our code directing to this issue. |
OK, after a bit of git-bisecting ... The "third child" example already worked as expected in v1.6.0 which is as far back as I can easily go on my dev machine. But the "second child" and "fourth child" cases were (as suspected) fixed by 1f483f0 which first appeared in v1.12.0 and was part of #2230 which fixed #1712 and #2228. See also #2246 which updated some tests to reflect this behavioral change. So: I'm closing this one out as "fixed in v1.12.0". Sorry for the delay and the confusion caused by leaving this open. |
Please see #2320 for more discussion about this change. |
Start with
Then
or
or even
Do it all, and you end up with
None of which is probably what you meant.
The only way I've been able to get the new element (and its children) to end up with no namespace is to traverse it after adding and explicitly set
node.namespace = nil
on everything.The text was updated successfully, but these errors were encountered: