-
-
Notifications
You must be signed in to change notification settings - Fork 904
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
Element#replace with CDATA raises error on JRuby #1666
Comments
I've found a workaround: if CDATA element is wrapped in
|
Apologies for the embarrassingly long response time. I've confirmed this behavior, investigating. |
OK, the offending code is at https://github.com/sparklemotion/nokogiri/blob/v1.8.2/ext/java/nokogiri/XmlNode.java#L1707-L1710 which I'll reproduce here: parentNode.replaceChild(otherNode, thisNode);
if (otherNode.getNodeType() != Node.TEXT_NODE) {
NokogiriHelpers.renameNode(otherNode, thisNode.getNamespaceURI(), otherNode.getNodeName());
} The first function call, The solution is going to be skipping that call for |
Closed by 80205c4 |
Thanks, @flavorjones :) |
Summary
When I try to replace element with CDATA on JRuby, I got an error
RuntimeError: org.jruby.exceptions.RaiseException: (RuntimeError) could not replace child: org.w3c.dom.DOMException: NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation.
. What is even more strange, element is replaced. It works without problems on MRI. Please, see examples below.Examples
Expected behaviour (MRI)
Actual behaviour (JRuby)
When I run the script line by line in console, it appears that
puts doc
gives the same result as on MRI:element is replaced, but error is raised afterwards.
Env info
Ubuntu 16.10
JRuby Nokogiri:
MRI Nokogiri:
The text was updated successfully, but these errors were encountered: