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