HTMLTableSectionElement
Represents the object for HTML table section (thead / tbody / tfoot) elements.
using AngleSharp.DOM.Collections;
using AngleSharp.DOM.Css;
namespace AngleSharp.DOM.Html
{
public sealed class HTMLTableSectionElement : HTMLElement
{
internal const string HeadTag = "thead";
internal const string BodyTag = "tbody";
internal const string FootTag = "tfoot";
[DOM("align")]
public HorizontalAlignment Align {
get {
return Element.ToEnum(GetAttribute("align"), HorizontalAlignment.Center);
}
set {
SetAttribute("align", value.ToString());
}
}
[DOM("rows")]
public HTMLCollection Rows {
get {
return _children.QuerySelectorAll(SimpleSelector.Type("tr"));
}
}
[DOM("vAlign")]
public VerticalAlignment VAlign {
get {
return Element.ToEnum(GetAttribute("valign"), VerticalAlignment.Middle);
}
set {
SetAttribute("valign", value.ToString());
}
}
protected internal override bool IsSpecial => true;
internal HTMLTableSectionElement()
{
_name = "tbody";
}
[DOM("insertRow")]
public HTMLTableRowElement InsertRow(int index)
{
Element element = Rows[index];
HTMLTableRowElement hTMLTableRowElement = base.OwnerDocument.CreateElement("tr") as HTMLTableRowElement;
if (element != null)
InsertBefore(hTMLTableRowElement, element);
else
AppendChild(hTMLTableRowElement);
return hTMLTableRowElement;
}
[DOM("deleteRow")]
public HTMLTableSectionElement DeleteRow(int index)
{
Rows[index]?.Remove();
return this;
}
}
}