diff --git a/ext/java/nokogiri/XmlNode.java b/ext/java/nokogiri/XmlNode.java
index 70440b53512..c74650cd6b9 100644
--- a/ext/java/nokogiri/XmlNode.java
+++ b/ext/java/nokogiri/XmlNode.java
@@ -978,10 +978,11 @@ public class XmlNode extends RubyObject
@JRubyMethod(visibility = Visibility.PROTECTED)
public IRubyObject
- initialize_copy_with_args(ThreadContext context, IRubyObject other, IRubyObject level, IRubyObject _ignored)
+ initialize_copy_with_args(ThreadContext context, IRubyObject other, IRubyObject level, IRubyObject document)
{
boolean deep = level instanceof RubyInteger && RubyFixnum.fix2int(level) != 0;
this.node = asXmlNode(context, other).node.cloneNode(deep);
+ setDocument(context, (XmlDocument)document);
return this;
}
diff --git a/test/xml/test_node.rb b/test/xml/test_node.rb
index 543e34c08c6..641b0dce5b6 100644
--- a/test/xml/test_node.rb
+++ b/test/xml/test_node.rb
@@ -238,8 +238,6 @@ def test_dup_same_parent_document_is_default
end
def test_dup_different_parent_document
- skip_unless_libxml2("Node.dup with new_parent arg is only implemented on CRuby")
-
doc1 = XML::Document.parse(" hello