ISparkExtension and adding attributes to IList<Node> in VisitNode

9 views
Skip to first unread message

Sean Chambers

unread,
Aug 11, 2010, 11:59:46 AM8/11/10
to Spark View Engine Dev
I am attempt to add a disabled attribute to an input ElementNode from
VisitNode in a custom ISparkExtension. This is code I am currently
trying but after adding the attribute to the tree and called
visitor.Accept(body), the attribute is not being written out at the
time of rendering.

var inputTags = body.Where(n => n is ElementNode && ((ElementNode)
n).Name == "input").Select(n => n as ElementNode);

AttributeNode disabledAttributeNode = new AttributeNode("disabled",
new List<Node>{new TextNode("disabled")});
inputTags.ForEach(inputNode =>
inputNode.Attributes.Add(disabledAttributeNode));

body.Insert( 0, _node );
body.Add( new EndElementNode( _node.Name ) );
visitor.Accept( body );


Is there something I am missing here if I alter the contents of body
after entering the VisitNode method? I'm assuming whatever is in the
tree at that time, prior to being passed to the visitor is fair game.

Thanks

Sean
Reply all
Reply to author
Forward
0 new messages