HtmlBaseElement
sealed class HtmlBaseElement : HtmlElement, IHtmlBaseElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle
Represents the HTML base element.
using AngleSharp.Dom.Css;
using AngleSharp.Extensions;
using AngleSharp.Html;
namespace AngleSharp.Dom.Html
{
internal sealed class HtmlBaseElement : HtmlElement, IHtmlBaseElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle
{
public string Href {
get {
return this.GetOwnAttribute(AttributeNames.Href);
}
set {
this.SetOwnAttribute(AttributeNames.Href, value);
}
}
public string Target {
get {
return this.GetOwnAttribute(AttributeNames.Target);
}
set {
this.SetOwnAttribute(AttributeNames.Target, value);
}
}
public HtmlBaseElement(Document owner, string prefix = null)
: base(owner, TagNames.Base, prefix, NodeFlags.SelfClosing | NodeFlags.Special)
{
}
private void UpdateUrl(string url)
{
base.Owner.BaseUrl = new Url(base.Owner.DocumentUrl, url ?? string.Empty);
}
internal override void SetupElement()
{
base.SetupElement();
string ownAttribute = this.GetOwnAttribute(AttributeNames.Href);
RegisterAttributeObserver(AttributeNames.Href, UpdateUrl);
if (ownAttribute != null)
UpdateUrl(ownAttribute);
}
}
}