HTMLOptionElement
Represents the HTML option element.
namespace AngleSharp.DOM.Html
{
[DOM("HTMLOptionElement")]
public sealed class HTMLOptionElement : HTMLElement, ISelectScopeElement, IImpliedEnd, IImplClosed
{
private bool? _selected;
[DOM("disabled")]
public bool Disabled {
get {
return GetAttribute("disabled") != null;
}
set {
SetAttribute("disabled", value ? string.Empty : null);
}
}
[DOM("form")]
public HTMLFormElement Form {
get {
return GetAssignedForm();
}
}
[DOM("label")]
public string Label {
get {
return GetAttribute("label");
}
set {
SetAttribute("label", value);
}
}
[DOM("value")]
public string Value {
get {
return GetAttribute("value") ?? string.Empty;
}
set {
SetAttribute("value", value);
}
}
[DOM("index")]
public int Index {
get {
HTMLOptGroupElement hTMLOptGroupElement = _parent as HTMLOptGroupElement;
if (hTMLOptGroupElement != null) {
int num = 0;
foreach (Element child in hTMLOptGroupElement.Children) {
if (child == this)
return num;
num++;
}
}
return 0;
}
}
[DOM("text")]
public string Text {
get {
return TextContent.CollapseAndStrip();
}
set {
TextContent = value;
}
}
[DOM("defaultSelected")]
public bool DefaultSelected {
get {
return GetAttribute("selected") != null;
}
set {
SetAttribute("selected", value ? string.Empty : null);
}
}
[DOM("selected")]
public bool Selected {
get {
if (!_selected.HasValue)
return DefaultSelected;
return _selected.Value;
}
set {
_selected = value;
}
}
protected internal override bool IsSpecial => false;
internal HTMLOptionElement()
{
_name = "option";
}
}
}