private DomNode ApplyClass(Action <DomStringTokenList> action) { var list = DomStringTokenList.Parse(Attribute("class")); action(list); return(Attribute("class", list.ToString())); }
internal static bool StaticContains(string text, DomStringTokenList names) { if (string.IsNullOrEmpty(text)) { return(false); } if (text.Length < names.ToString().Length) { return(false); } return(DomStringTokenList.Parse(text).IsSupersetOf(names)); }
public virtual DomElementCollection GetElementsByClassName(string className) { if (string.IsNullOrEmpty(className)) { return(DomElementCollection.Empty); } var names = DomStringTokenList.Parse(className); return(new DefaultDomElementCollection( this, n => n.Descendants.Where(t => DomStringTokenList.StaticContains(t.Attribute("class"), names)) )); }
public bool HasClass(string name) { var list = Attribute <DomStringTokenList>("class"); if (list == null) { return(false); } var names = DomStringTokenList.Parse(name); if (names.Count == 0) { return(false); } return(names.All(n => list.Contains(n))); }
private IEnumerable <TKey> GetKeys(string value) { return(DomStringTokenList.Parse(value).Select(Key)); }
public DomNode RemoveClass(string classNames) { return(ApplyClass(l => l.RemoveRange(DomStringTokenList.Parse(classNames)))); }
public DomNode AddClass(string classNames) { return(ApplyClass(l => l.AddRange(DomStringTokenList.Parse(classNames)))); }