XNodeNavigator could be used for a node tree without XDocument, so make it work for...
[mono.git] / mcs / class / System.Xml.Linq / System.Xml.Linq / XNodeNavigator.cs
index 31138a00135f8050caeaa62817476b88edff20a8..84cb492334cf8ffe9c05502aac3e32e9ebd328f2 100644 (file)
@@ -413,8 +413,12 @@ namespace System.Xml.Linq
 
                public override void MoveToRoot ()
                {
-                       node = node.Document ?? node;
                        attr = null;
+                       if (node.Document != null)
+                               node = node.Document;
+                       else
+                               while (node.Owner != null)
+                                       node = node.Owner;
                }
        }
 }