提交 90219108 编写于 作者: A Atsushi Eno

Do not return DocumentFragment from AppendChild() etc. Fixed bug #666249.

上级 c410acbb
......@@ -540,10 +540,13 @@ namespace System.Xml
if (newChild.NodeType == XmlNodeType.DocumentFragment) {
// This recursively invokes events. (It is compatible with MS implementation.)
while (newChild.FirstChild != null)
this.InsertBefore (newChild.FirstChild, refChild);
}
else {
XmlNode ret = null;
while (newChild.FirstChild != null) {
var c = this.InsertBefore (newChild.FirstChild, refChild);
ret = ret ?? c;
}
return ret;
} else {
XmlLinkedNode newLinkedChild = (XmlLinkedNode) newChild;
newLinkedChild.parentNode = this;
......@@ -585,8 +588,8 @@ namespace System.Xml
if (raiseEvent)
ownerDoc.onNodeInserted (newChild, newChild.ParentNode);
return newChild;
}
return newChild;
}
private void CheckNodeInsertion (XmlNode newChild, XmlNode refChild)
......
......@@ -57,11 +57,12 @@ namespace MonoTests.System.Xml
fragment.AppendChild (document.CreateElement ("div"));
// appending fragment to element
body.AppendChild (fragment);
XmlNode ret = body.AppendChild (fragment);
Assert.IsNotNull (body.FirstChild, "#AppendFragmentToElement.Exist");
Assert.AreEqual (XmlNodeType.Element, body.FirstChild.NodeType, "#AppendFragmentToElement.ChildIsElement");
Assert.AreEqual ("p", body.FirstChild.Name, "#AppendFragmentToElement.FirstChild");
Assert.AreEqual ("div", body.LastChild.Name, "#AppendFragmentToElement.LastChild");
Assert.AreEqual ("p", ret.LocalName, "#AppendFragmentToElement.ReturnValue");
}
[Test]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册