CompoundSelector
Represents a compound selector.
Chain of simple selectors which are not separated by
a combinator.
using System.Text;
namespace AngleSharp.Dom.Css
{
internal sealed class CompoundSelector : Selectors, ISelector, IStyleFormattable
{
internal static CompoundSelector Create(params SimpleSelector[] selectors)
{
CompoundSelector compoundSelector = new CompoundSelector();
for (int i = 0; i < selectors.Length; i++) {
compoundSelector.selectors.Add(selectors[i]);
}
return compoundSelector;
}
public bool Match(IElement element)
{
for (int i = 0; i < selectors.Count; i++) {
if (!selectors[i].Match(element))
return false;
}
return true;
}
public override string ToCss()
{
StringBuilder stringBuilder = Pool.NewStringBuilder();
for (int i = 0; i < selectors.Count; i++) {
stringBuilder.Append(selectors[i].Text);
}
return stringBuilder.ToPool();
}
}
}