public void NodeNameComesFirst() { // parsing attributes is slowww....... // we are delaying parsing them until something actually tries to read the attributes // therefore, if we are doing css path selection, we should always test name before // we test attributes. // Given: a node that has attributes var node = this.Parse("<root a='a' b='b' ></rot>"); // And: a selector that does not match the nodes name var cssExpression = new CssExpression("tag.class#id:first-child"); // When: the select checks the node bool isMatch = cssExpression.IsMatch(node); // Then: is not a match Assert.False(isMatch); // And: attributes were never parsed/loaded object internalAttributes = node .GetType() .GetField("_attributes", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(node); Assert.IsNull(internalAttributes); }
public void Selector_RoundTrip(string origCss) { // all of these selectors.ToString() should come back as the original string. // selectors return attribute-names in lowercase and attribute values quoted in single quotes (') var selector = new CssExpression(origCss); string andBack = selector.ToString(); Assert.That(andBack, Is.EqualTo(origCss)); }
public CssValue(CssExpression expression) : base(CssType.Instance) { this.expression = expression; }
public CssSelector(string text) { _expression = CssExpressionParser.Parse(new StringReader(text)); Specificity = _expression.GetSpecificity(); }