public void ConditionalAttributeCollapserDoesNotRewriteEscapedTransitions() { // Act var results = ParseDocument("<span foo='@@' />"); var attributeCollapser = new ConditionalAttributeCollapser(); var rewritten = attributeCollapser.Rewrite(results.Root); // Assert BaselineTest(rewritten); }
public void ConditionalAttributeCollapserDoesNotRewriteEscapedTransitions() { // Act var results = ParseDocument("<span foo='@@' />"); var attributeCollapser = new ConditionalAttributeCollapser(); var rewritten = attributeCollapser.Rewrite(results.Root); // Assert EvaluateParseTree(rewritten, new MarkupBlock( new MarkupTagBlock( Factory.Markup("<span"), new MarkupBlock( new AttributeBlockChunkGenerator("foo", new LocationTagged <string>(" foo='", 5, 0, 5), new LocationTagged <string>("'", 13, 0, 13)), Factory.Markup(" foo='").With(SpanChunkGenerator.Null), new MarkupBlock( Factory.Markup("@").With(new LiteralAttributeChunkGenerator(new LocationTagged <string>(string.Empty, 11, 0, 11), new LocationTagged <string>("@", 11, 0, 11))).Accepts(AcceptedCharactersInternal.None), Factory.Markup("@").With(SpanChunkGenerator.Null).Accepts(AcceptedCharactersInternal.None)), Factory.Markup("'").With(SpanChunkGenerator.Null)), Factory.Markup(" />")))); }
public void ConditionalAttributesDoNotCreateExtraDataForEntirelyLiteralAttribute() { // Arrange const string code = @"<div class=""sidebar""> <h1>Title</h1> <p> As the author, you can <a href=""/Photo/Edit/photoId"">edit</a> or <a href=""/Photo/Remove/photoId"">remove</a> this photo. </p> <dl> <dt class=""description"">Description</dt> <dd class=""description""> The uploader did not provide a description for this photo. </dd> <dt class=""uploaded-by"">Uploaded by</dt> <dd class=""uploaded-by""><a href=""/User/View/user.UserId"">user.DisplayName</a></dd> <dt class=""upload-date"">Upload date</dt> <dd class=""upload-date"">photo.UploadDate</dd> <dt class=""part-of-gallery"">Gallery</dt> <dd><a href=""/View/gallery.Id"" title=""View gallery.Name gallery"">gallery.Name</a></dd> <dt class=""tags"">Tags</dt> <dd class=""tags""> <ul class=""tags""> <li>This photo has no tags.</li> </ul> <a href=""/Photo/EditTags/photoId"">edit tags</a> </dd> </dl> <p> <a class=""download"" href=""/Photo/Full/photoId"" title=""Download: (photo.FileTitle + photo.FileExtension)"">Download full photo</a> ((photo.FileSize / 1024) KB) </p> </div> <div class=""main""> <img class=""large-photo"" alt=""photo.FileTitle"" src=""/Photo/Thumbnail"" /> <h2>Nobody has commented on this photo</h2> <ol class=""comments""> <li> <h3 class=""comment-header""> <a href=""/User/View/comment.UserId"" title=""View comment.DisplayName's profile"">comment.DisplayName</a> commented at comment.CommentDate: </h3> <p class=""comment-body"">comment.CommentText</p> </li> </ol> <form method=""post"" action=""""> <fieldset id=""addComment""> <legend>Post new comment</legend> <ol> <li> <label for=""newComment"">Comment</label> <textarea id=""newComment"" name=""newComment"" title=""Your comment"" rows=""6"" cols=""70""></textarea> </li> </ol> <p class=""form-actions""> <input type=""submit"" title=""Add comment"" value=""Add comment"" /> </p> </fieldset> </form> </div>"; // Act var results = ParseDocument(code); var attributeCollapser = new ConditionalAttributeCollapser(); var rewritten = attributeCollapser.Rewrite(results.Root); // Assert Assert.Equal(rewritten.Children.Count(), results.Root.Children.Count()); }