CsQuery.CQ.GetTrueTarget C# (CSharp) Метод

GetTrueTarget() приватный Метод

Deals with tbody as the target of appends.
private GetTrueTarget ( IDomElement target ) : IDomElement
target IDomElement /// The true target. ///
Результат IDomElement
        private IDomElement GetTrueTarget(IDomElement target)
        {
            //Special handling for tables: make sure we add to the TBODY
            IDomElement element = target;
            if (target.NodeNameID == HtmlData.tagTABLE)
            {
                bool addBody = false;
                if (target.HasChildren)
                {
                    IDomElement body = target.ChildElements.FirstOrDefault(item => item.NodeNameID == HtmlData.tagTBODY);
                    if (body != null)
                    {
                        element = body;
                    }
                    else if (target.FirstElementChild == null)
                    {
                        // Add a body if there are no elements in this table yet
                        addBody = true;
                    }
                    // default = leave it alone, they've already added elements. don't worry whether it's valid or not, 
                    // assume they know what they're doing.
                }
                else
                {
                    addBody = true;
                }
                if (addBody)
                {
                    element = Document.CreateElement("tbody");
                    target.AppendChild(element);
                }
            }
            return element;
        }