AngleSharp by Florian Rappl

<PackageReference Include="AngleSharp" Version="0.6.1" />

.NET API 886,784 bytes

 HTMLStyleElement

Represents the HTML style element.
using AngleSharp.DOM.Css; namespace AngleSharp.DOM.Html { internal sealed class HTMLStyleElement : HTMLElement, IHtmlStyleElement, IHtmlElement, IElement, INode, IEventTarget, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle, ILinkStyle { private IStyleSheet _sheet; public bool IsScoped { get { return GetAttribute(AttributeNames.Scoped) != null; } set { SetAttribute(AttributeNames.Scoped, value ? string.Empty : null); } } public IStyleSheet Sheet => _sheet; public bool IsDisabled { get { if (_sheet != null) return _sheet.IsDisabled; return false; } set { if (_sheet != null) _sheet.IsDisabled = value; } } public string Media { get { return GetAttribute(AttributeNames.Media); } set { SetAttribute(AttributeNames.Media, value); } } public string Type { get { return GetAttribute(AttributeNames.Type); } set { SetAttribute(AttributeNames.Type, value); } } internal HTMLStyleElement() : base(Tags.Style, NodeFlags.Special | NodeFlags.LiteralText) { } internal override void Close() { base.Close(); RegisterAttributeHandler(AttributeNames.Media, delegate { if (_sheet != null) _sheet.Media.MediaText = Media; }); UpdateSheet(); } internal override void NodeIsInserted(Node newNode) { base.NodeIsInserted(newNode); UpdateSheet(); } internal override void NodeIsRemoved(Node removedNode, Node oldPreviousSibling) { base.NodeIsRemoved(removedNode, oldPreviousSibling); UpdateSheet(); } private void UpdateSheet() { if (base.Owner.Options.IsStyling) _sheet = base.Owner.Options.ParseStyling(TextContent, this, Type); } } }