HtmlTableRowElement
sealed class HtmlTableRowElement : HtmlElement, IHtmlTableRowElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IGlobalEventHandlers
Represents the HTML tr element.
using AngleSharp.Dom;
using AngleSharp.Dom.Events;
using AngleSharp.Text;
using System.Runtime.CompilerServices;
namespace AngleSharp.Html.Dom
{
internal sealed class HtmlTableRowElement : HtmlElement, IHtmlTableRowElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IGlobalEventHandlers
{
[System.Runtime.CompilerServices.Nullable(new byte[] {
2,
1
})]
private HtmlCollection<IHtmlTableCellElement> _cells;
public HorizontalAlignment Align {
get {
return this.GetOwnAttribute(AttributeNames.Align).ToEnum(HorizontalAlignment.Left);
}
set {
this.SetOwnAttribute(AttributeNames.Align, value.ToString(), false);
}
}
public VerticalAlignment VAlign {
get {
return this.GetOwnAttribute(AttributeNames.Valign).ToEnum(VerticalAlignment.Middle);
}
set {
this.SetOwnAttribute(AttributeNames.Valign, value.ToString(), false);
}
}
[System.Runtime.CompilerServices.Nullable(2)]
public string BgColor {
[System.Runtime.CompilerServices.NullableContext(2)]
get {
return this.GetOwnAttribute(AttributeNames.BgColor);
}
[System.Runtime.CompilerServices.NullableContext(2)]
set {
this.SetOwnAttribute(AttributeNames.BgColor, value, false);
}
}
[System.Runtime.CompilerServices.Nullable(1)]
public IHtmlCollection<IHtmlTableCellElement> Cells {
[System.Runtime.CompilerServices.NullableContext(1)]
get {
return _cells ?? (_cells = new HtmlCollection<IHtmlTableCellElement>(this, false, null));
}
}
public int Index => this.GetAncestor<IHtmlTableElement>()?.Rows.Index(this) ?? (-1);
public int IndexInSection => (base.ParentElement as IHtmlTableSectionElement)?.Rows.Index(this) ?? Index;
[System.Runtime.CompilerServices.NullableContext(1)]
public HtmlTableRowElement(Document owner, [System.Runtime.CompilerServices.Nullable(2)] string prefix = null)
: base(owner, TagNames.Tr, prefix, NodeFlags.Special | NodeFlags.ImplicitlyClosed)
{
}
[System.Runtime.CompilerServices.NullableContext(1)]
public IHtmlTableCellElement InsertCellAt(int index = -1, TableCellKind tableCellKind = TableCellKind.Td)
{
IHtmlCollection<IHtmlTableCellElement> cells = Cells;
IHtmlTableCellElement htmlTableCellElement = (IHtmlTableCellElement)base.Owner.CreateElement((tableCellKind == TableCellKind.Td) ? TagNames.Td : TagNames.Th);
if (index >= 0 && index < cells.Length)
InsertBefore(htmlTableCellElement, cells[index]);
else
AppendChild(htmlTableCellElement);
return htmlTableCellElement;
}
public void RemoveCellAt(int index)
{
IHtmlCollection<IHtmlTableCellElement> cells = Cells;
if (index < 0)
index = cells.Length + index;
if (index >= 0 && index < cells.Length)
cells[index].Remove();
}
}
}