/// <summary> /// Fills the given parent style with declarations given by the tokens. /// </summary> public void FillDeclarations(CssStyleDeclaration style) { var token = _tokenizer.Get(); while (token.IsNot(CssTokenType.Eof, CssTokenType.CurlyBracketClose)) { var property = CreateDeclaration(ref token); if (property != null && property.HasValue) style.SetProperty(property); } }
/// <summary> /// Fills the given parent style with declarations given by the tokens. /// </summary> public TextPosition FillDeclarations(CssStyleDeclaration style) { var token = NextToken(); _nodes.Push(style); CollectTrivia(ref token); while (token.IsNot(CssTokenType.EndOfFile, CssTokenType.CurlyBracketClose)) { var property = CreateDeclarationWith(Factory.Properties.Create, ref token); if (property != null && property.HasValue) { style.SetProperty(property); } CollectTrivia(ref token); } _nodes.Pop(); return token.Position; }
public void CssPropertyFactoryCalls() { var parser = new CssParser(); var decl = new CssStyleDeclaration(parser); var invalid = decl.CreateProperty("invalid"); var border = decl.CreateProperty("border"); var color = decl.CreateProperty("color"); decl.SetProperty(color); var colorAgain = decl.CreateProperty("color"); Assert.IsNull(invalid); Assert.IsNotNull(border); Assert.IsNotNull(color); Assert.IsNotNull(colorAgain); Assert.IsInstanceOf<CssBorderProperty>(border); Assert.IsInstanceOf<CssColorProperty>(color); Assert.AreEqual(color, colorAgain); }