static IChain <T> MergeCssAttributes <T> (this IChain <T> chain) where T : HAttribute, new() { if (!chain.ToEnumerable().Any(a => a.Name == "class")) { return(chain); } var combinedCss = MergeCss(chain.ToEnumerable().Where(a => a.Name == "class" && a.Value != null).Select(a => "" + a.Value).ToList()); var cssAttribute = (T) new T().Create("class", combinedCss); return(new Chain <T> (chain.ToEnumerable().Where(a => a.Name != "class").Concat(new T[] { cssAttribute }))); }
public HElement(string name, IChain <HAttribute> attributes, IEnumerable <object> children) : base(children) { this.Name = name; if (attributes != null) { Attributes = attributes.ToEnumerable().Where(a => a.Value != null).ToList(); } Validate(); }
public static IChain <T> Join <T> (this IChain <T> x, IChain <T> y) { if (x == null && y == null) { return(new Chain <T> (null)); } if (x == null) { return(y); } if (y == null) { return(x); } return(new Chain <T> (x.ToEnumerable().Concat(y.ToEnumerable()))); }
public HElement(string name, IChain<HAttribute> attributes, IEnumerable<object> children) : base(children) { this.Name = name; if (attributes != null) Attributes = attributes.ToEnumerable ().Where (a => a.Value != null).ToList (); Validate (); }