Skip to content

Commit

Permalink
Update HtmlNode.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMagnan committed Aug 23, 2023
1 parent 16845ad commit 545befc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/HtmlAgilityPack.Shared/HtmlNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,21 @@ public HtmlNode AppendChild(HtmlNode newChild)
_ownerdocument.SetIdForNode(newChild, newChild.GetId());
SetChildNodesId(newChild);

var parentnode = _parentnode;
HtmlDocument lastOwnerDocument = null;
while (parentnode != null)
{
if(parentnode.OwnerDocument != lastOwnerDocument)
{
parentnode.OwnerDocument.SetIdForNode(newChild, newChild.GetId());
parentnode.SetChildNodesId(newChild);
lastOwnerDocument = parentnode.OwnerDocument;
}

parentnode = parentnode._parentnode;
}


SetChanged();
return newChild;
}
Expand Down

0 comments on commit 545befc

Please sign in to comment.