HTMLOptionElement
Represents the HTML option element.
namespace AngleSharp.DOM.Html
{
[DOM("HTMLOptionElement")]
public sealed class HTMLOptionElement : HTMLElement
{
internal const string Tag = "option";
private bool selectedness;
[DOM("name")]
public string Name {
get {
return GetAttribute("name");
}
set {
SetAttribute("name", value);
}
}
[DOM("disabled")]
public bool Disabled {
get {
return GetAttribute("disabled") != null;
}
set {
SetAttribute("disabled", value ? string.Empty : null);
}
}
[DOM("form")]
public HTMLFormElement Form {
get {
if (_parent != null && _parent is HTMLSelectElement)
return ((HTMLSelectElement)_parent).Form;
return null;
}
}
[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) {
for (int i = 0; i < hTMLOptGroupElement.ChildElementCount; i++) {
if (hTMLOptGroupElement.Children[i] == this)
return i;
}
}
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 {
return selectedness;
}
set {
selectedness = value;
}
}
protected internal override bool IsSpecial => false;
internal HTMLOptionElement()
{
_name = "option";
Selected = false;
}
}
}