HtmlAnchorElement
sealed class HtmlAnchorElement : HtmlElement, IHtmlAnchorElement, IHtmlElement, IElement, INode, IEventTarget, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle, IUrlUtilities
Represents an anchor element.
using AngleSharp.Dom.Collections;
using AngleSharp.Dom.Css;
using AngleSharp.Html;
namespace AngleSharp.Dom.Html
{
internal sealed class HtmlAnchorElement : HtmlElement, IHtmlAnchorElement, IHtmlElement, IElement, INode, IEventTarget, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle, IUrlUtilities
{
private readonly BoundLocation _location;
private TokenList _relList;
private SettableTokenList _ping;
public string Charset {
get {
return GetAttribute(AttributeNames.Charset);
}
set {
SetAttribute(AttributeNames.Charset, value);
}
}
public string Download {
get {
return GetAttribute(AttributeNames.Download);
}
set {
SetAttribute(AttributeNames.Download, value);
}
}
public string Href {
get {
return _location.Href;
}
set {
_location.Href = value;
}
}
public string Hash {
get {
return _location.Hash;
}
set {
_location.Hash = value;
}
}
public string Host {
get {
return _location.Host;
}
set {
_location.Host = value;
}
}
public string HostName {
get {
return _location.HostName;
}
set {
_location.HostName = value;
}
}
public string PathName {
get {
return _location.PathName;
}
set {
_location.PathName = value;
}
}
public string Port {
get {
return _location.Port;
}
set {
_location.Port = value;
}
}
public string Protocol {
get {
return _location.Protocol;
}
set {
_location.Protocol = value;
}
}
public string UserName {
get {
return _location.UserName;
}
set {
_location.UserName = value;
}
}
public string Password {
get {
return _location.Password;
}
set {
_location.Password = value;
}
}
public string Search {
get {
return _location.Search;
}
set {
_location.Search = value;
}
}
public string Origin => _location.Origin;
public string TargetLanguage {
get {
return GetAttribute(AttributeNames.HrefLang);
}
set {
SetAttribute(AttributeNames.HrefLang, value);
}
}
public string Media {
get {
return GetAttribute(AttributeNames.Media);
}
set {
SetAttribute(AttributeNames.Media, value);
}
}
public string Name {
get {
return GetAttribute(AttributeNames.Name);
}
set {
SetAttribute(AttributeNames.Name, value);
}
}
public string Relation {
get {
return GetAttribute(AttributeNames.Rel);
}
set {
SetAttribute(AttributeNames.Rel, value);
}
}
public ITokenList RelationList {
get {
if (_relList == null) {
_relList = new TokenList(GetAttribute(AttributeNames.Rel));
_relList.Changed += delegate {
UpdateAttribute(AttributeNames.Rel, _relList.ToString());
};
}
return _relList;
}
}
public ISettableTokenList Ping {
get {
if (_ping == null) {
_ping = new SettableTokenList(GetAttribute(AttributeNames.Ping));
_ping.Changed += delegate {
UpdateAttribute(AttributeNames.Ping, _ping.Value);
};
}
return _ping;
}
}
public string Target {
get {
return GetAttribute(AttributeNames.Target);
}
set {
SetAttribute(AttributeNames.Target, value);
}
}
public string Text {
get {
return TextContent;
}
set {
TextContent = value;
}
}
public string Type {
get {
return GetAttribute(AttributeNames.Type);
}
set {
SetAttribute(AttributeNames.Type, value);
}
}
internal bool IsVisited { get; set; }
internal bool IsActive { get; set; }
public HtmlAnchorElement(Document owner)
: base(owner, Tags.A, NodeFlags.HtmlFormatting)
{
_location = new BoundLocation(this);
RegisterAttributeObserver(AttributeNames.Rel, UpdateRelList);
}
public override void DoFocus()
{
if (GetAttribute(AttributeNames.Href) != null)
base.IsFocused = true;
}
private void UpdateRelList(string value)
{
if (_relList != null)
_relList.Update(value);
}
}
}