SvgElement
class SvgElement : Element, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle
Represents an element of the SVG DOM.
using AngleSharp.Dom.Css;
using AngleSharp.Extensions;
using AngleSharp.Html;
using System;
namespace AngleSharp.Dom.Svg
{
internal class SvgElement : Element, ISvgElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle
{
private ICssStyleDeclaration _style;
public ICssStyleDeclaration Style => _style ?? (_style = CreateStyle());
public SvgElement(Document owner, string name, string prefix = null, NodeFlags flags = NodeFlags.None)
: base(owner, name, prefix, Namespaces.SvgUri, flags | NodeFlags.SvgMember)
{
string style = AttributeNames.Style;
Action<string> callback = delegate(string value) {
IBindable bindable = _style as IBindable;
if (string.IsNullOrEmpty(value))
base.Attributes.Remove(base.Attributes.Get(null, AttributeNames.Style));
bindable?.Update(value);
};
RegisterAttributeObserver(style, callback);
}
public override INode Clone(bool deep = true)
{
SvgElement svgElement = Factory.SvgElements.Create(base.Owner, base.LocalName, base.Prefix);
Node.CopyProperties(this, svgElement, deep);
Element.CopyAttributes(this, svgElement);
return svgElement;
}
}
}