AngleSharp by AngleSharp

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

.NET API 1,230,336 bytes

 HtmlSlotElement

Represents an HTML slot element.
using AngleSharp.Dom.Css; using AngleSharp.Dom.Events; using AngleSharp.Extensions; using AngleSharp.Html; using System.Collections.Generic; using System.Linq; namespace AngleSharp.Dom.Html { internal sealed class HtmlSlotElement : HtmlElement, IHtmlSlotElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle, IGlobalEventHandlers { public string Name { get { return this.GetOwnAttribute(AttributeNames.Name); } set { this.SetOwnAttribute(AttributeNames.Name, value, false); } } public HtmlSlotElement(Document owner, string prefix = null) : base(owner, TagNames.Slot, prefix, NodeFlags.None) { } public IEnumerable<INode> GetDistributedNodes() { IElement element = this.GetAncestor<IShadowRoot>()?.Host; if (element != null) { List<INode> list = new List<INode>(); { foreach (INode childNode in element.ChildNodes) { if (GetAssignedSlot(childNode) == this) { HtmlSlotElement htmlSlotElement = childNode as HtmlSlotElement; if (htmlSlotElement != null) list.AddRange(htmlSlotElement.GetDistributedNodes()); else list.Add(childNode); } } return list; } } return Enumerable.Empty<INode>(); } private static IElement GetAssignedSlot(INode node) { switch (node.NodeType) { case NodeType.Text: return ((IText)node).AssignedSlot; case NodeType.Element: return ((IElement)node).AssignedSlot; default: return null; } } } }