HtmlTableSectionElement
sealed class HtmlTableSectionElement : HtmlElement, IHtmlTableSectionElement, IHtmlElement, IElement, INode, IEventTarget, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle
Represents the object for HTML table section (thead / tbody / tfoot) elements.
using AngleSharp.Dom.Collections;
using AngleSharp.Dom.Css;
using AngleSharp.Extensions;
using AngleSharp.Html;
namespace AngleSharp.Dom.Html
{
internal sealed class HtmlTableSectionElement : HtmlElement, IHtmlTableSectionElement, IHtmlElement, IElement, INode, IEventTarget, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle
{
private readonly HtmlCollection<IHtmlTableRowElement> _rows;
public HorizontalAlignment Align {
get {
return GetAttribute(AttributeNames.Align).ToEnum(HorizontalAlignment.Center);
}
set {
SetAttribute(AttributeNames.Align, value.ToString());
}
}
public IHtmlCollection Rows => _rows;
public VerticalAlignment VAlign {
get {
return GetAttribute(AttributeNames.Valign).ToEnum(VerticalAlignment.Middle);
}
set {
SetAttribute(AttributeNames.Valign, value.ToString());
}
}
public HtmlTableSectionElement(Document owner, string name)
: base(owner, name, NodeFlags.Special | NodeFlags.ImplicitelyClosed | NodeFlags.HtmlTableSectionScoped)
{
_rows = new HtmlCollection<IHtmlTableRowElement>(this, true, null);
}
public IHtmlElement InsertRowAt(int index = -1)
{
IElement element = Rows[index];
IHtmlTableRowElement htmlTableRowElement = base.Owner.CreateElement(Tags.Tr) as IHtmlTableRowElement;
if (element != null)
InsertBefore(htmlTableRowElement, element);
else
AppendChild(htmlTableRowElement);
return htmlTableRowElement;
}
public void RemoveRowAt(int index)
{
Rows[index]?.Remove();
}
}
}