Exemplo n.º 1
0
        /// <summary>The <see cref="AttribNode"/> visit implementation</summary>
        /// <param name="attrib">The attrib AST node</param>
        /// <returns>The modified AST node if modified otherwise the original node</returns>
        public override AstNode VisitAttribNode(AttribNode attrib)
        {
            // attrib
            // : '[' S* [ namespace_prefix ]? IDENT S*
            // [ [ PREFIXMATCH |
            // SUFFIXMATCH |
            // SUBSTRINGMATCH |
            // '=' |
            // INCLUDES |
            // DASHMATCH ] S* [ IDENT | STRING ] S*
            // ]? ']'
            // ;

            // append for: '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S* [ IDENT | STRING ] S* ]? ']'
            _printerFormatter.Append(CssConstants.OpenSquareBracket);

            if (attrib.SelectorNamespacePrefixNode != null)
            {
                attrib.SelectorNamespacePrefixNode.Accept(this);
            }

            _printerFormatter.Append(attrib.Ident);

            if (attrib.OperatorAndValueNode != null)
            {
                attrib.OperatorAndValueNode.Accept(this);
            }

            _printerFormatter.Append(CssConstants.CloseSquareBracket);

            return(attrib);
        }
 /// <summary>The <see cref="Ast.Selectors.AttribNode"/> visit implementation</summary>
 /// <param name="attrib">The attrib AST node</param>
 /// <returns>The modified AST node if modified otherwise the original node</returns>
 public override AstNode VisitAttribNode(AttribNode attrib)
 {
     return(new AttribNode(
                attrib.SelectorNamespacePrefixNode != null ? (SelectorNamespacePrefixNode)attrib.SelectorNamespacePrefixNode.Accept(this) : null,
                attrib.Ident,
                (AttribOperatorAndValueNode)attrib.OperatorAndValueNode.Accept(this)));
 }
        /// <summary>Creates the list of hash class attrib pseudo nodes.</summary>
        /// <param name="hashClassAttribPseudoNegationTreeNodes">The hash class attrib pseudo node tree.</param>
        /// <returns>The list of hash class attrib pseudo nodes.</returns>
        private static IEnumerable <HashClassAtNameAttribPseudoNegationNode> CreateHashClassAttribPseudoNegationNodes(IEnumerable <CommonTree> hashClassAttribPseudoNegationTreeNodes)
        {
            return(hashClassAttribPseudoNegationTreeNodes.Select(hashClassAttribPseudoNegationNode =>
            {
                var child = hashClassAttribPseudoNegationNode.Children().FirstOrDefault();
                string hash = null;
                string replacementToken = null;
                string cssClass = null;
                string atName = null;
                AttribNode attribNode = null;
                PseudoNode pseudoNode = null;
                NegationNode negationNode = null;

                if (child != null)
                {
                    var nodeText = child.Text;
                    if (nodeText == T(CssParser.HASHIDENTIFIER))
                    {
                        hash = child.FirstChildText();
                    }
                    else if (nodeText == T(CssParser.CLASSIDENTIFIER))
                    {
                        cssClass = child.FirstChildText();
                    }
                    else if (nodeText == T(CssParser.ATIDENTIFIER))
                    {
                        atName = child.FirstChildText();
                    }
                    else if (nodeText == T(CssParser.ATTRIBIDENTIFIER))
                    {
                        attribNode = CreateAttribNode(child);
                    }
                    else if (nodeText == T(CssParser.PSEUDOIDENTIFIER))
                    {
                        pseudoNode = CreatePseudoNode(child);
                    }
                    else if (nodeText == T(CssParser.NEGATIONIDENTIFIER))
                    {
                        negationNode = CreateNegationNode(child);
                    }
                    else if (nodeText == T(CssParser.REPLACEMENTTOKENIDENTIFIER))
                    {
                        replacementToken = child.FirstChildText();
                    }
                }

                return new HashClassAtNameAttribPseudoNegationNode(hash, cssClass, replacementToken, atName, attribNode, pseudoNode, negationNode);
            }));
        }
Exemplo n.º 4
0
 /// <summary>The <see cref="Ast.Selectors.AttribNode"/> visit implementation</summary>
 /// <param name="attrib">The attrib AST node</param>
 /// <returns>The modified AST node if modified otherwise the original node</returns>
 public virtual AstNode VisitAttribNode(AttribNode attrib)
 {
     return(attrib);
 }