Skip to content

Commit 802cd85

Browse files
Copilotdavidwengier
andcommitted
Add parser test for attributes after Razor comments
Added test to verify the HTML parser correctly handles attributes after Razor comments. Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
1 parent f5bf085 commit 802cd85

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/HtmlAttributeTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,12 @@ public void ConditionalAttribute_CommentBefore()
344344
ParseDocumentTest("""<p @* comment *@ class="@c" />""");
345345
}
346346

347+
[Fact, WorkItem("https://github.com/dotnet/razor/issues/12261")]
348+
public void AttributeAfterComment()
349+
{
350+
ParseDocumentTest("""<p class="first" @* comment *@ data-value="second" />""");
351+
}
352+
347353
[Fact]
348354
public void EscapedAttributeName_WithValue()
349355
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Markup span at (0:0,0 [2] ) - Parent: Tag block at (0:0,0 [53] )
2+
Markup span at (2:0,2 [8] ) - Parent: Markup block at (2:0,2 [14] )
3+
Markup span at (10:0,10 [5] ) - Parent: Markup block at (2:0,2 [14] )
4+
Markup span at (15:0,15 [1] ) - Parent: Markup block at (2:0,2 [14] )
5+
Markup span at (16:0,16 [1] ) - Parent: Tag block at (0:0,0 [53] )
6+
Transition span at (17:0,17 [1] ) - Parent: Comment block at (17:0,17 [13] )
7+
MetaCode span at (18:0,18 [1] ) - Parent: Comment block at (17:0,17 [13] )
8+
Comment span at (19:0,19 [9] ) - Parent: Comment block at (17:0,17 [13] )
9+
MetaCode span at (28:0,28 [1] ) - Parent: Comment block at (17:0,17 [13] )
10+
Transition span at (29:0,29 [1] ) - Parent: Comment block at (17:0,17 [13] )
11+
Markup span at (30:0,30 [13] ) - Parent: Markup block at (30:0,30 [20] )
12+
Markup span at (43:0,43 [6] ) - Parent: Markup block at (30:0,30 [20] )
13+
Markup span at (49:0,49 [1] ) - Parent: Markup block at (30:0,30 [20] )
14+
Markup span at (50:0,50 [3] ) - Parent: Tag block at (0:0,0 [53] )
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
RazorDocument - [0..53)::53 - [<p class="first" @* comment *@ data-value="second" />]
2+
MarkupBlock - [0..53)::53
3+
MarkupElement - [0..53)::53
4+
MarkupStartTag - [0..53)::53 - [<p class="first" @* comment *@ data-value="second" />] - Gen<Markup>
5+
OpenAngle;[<];
6+
Text;[p];
7+
MarkupAttributeBlock - [2..16)::14 - [ class="first"]
8+
MarkupTextLiteral - [2..3)::1 - [ ] - Gen<Markup>
9+
Whitespace;[ ];
10+
MarkupTextLiteral - [3..8)::5 - [class] - Gen<Markup>
11+
Text;[class];
12+
Equals;[=];
13+
MarkupTextLiteral - [9..10)::1 - ["] - Gen<Markup>
14+
DoubleQuote;["];
15+
GenericBlock - [10..15)::5
16+
MarkupLiteralAttributeValue - [10..15)::5 - [first]
17+
MarkupTextLiteral - [10..15)::5 - [first] - Gen<Markup>
18+
Text;[first];
19+
MarkupTextLiteral - [15..16)::1 - ["] - Gen<Markup>
20+
DoubleQuote;["];
21+
MarkupTextLiteral - [16..17)::1 - [ ] - Gen<Markup>
22+
Whitespace;[ ];
23+
RazorComment - [17..30)::13
24+
RazorCommentTransition;[@];
25+
RazorCommentStar;[*];
26+
RazorCommentLiteral;[ comment ];
27+
RazorCommentStar;[*];
28+
RazorCommentTransition;[@];
29+
MarkupAttributeBlock - [30..50)::20 - [ data-value="second"]
30+
MarkupTextLiteral - [30..31)::1 - [ ] - Gen<Markup>
31+
Whitespace;[ ];
32+
MarkupTextLiteral - [31..41)::10 - [data-value] - Gen<Markup>
33+
Text;[data-value];
34+
Equals;[=];
35+
MarkupTextLiteral - [42..43)::1 - ["] - Gen<Markup>
36+
DoubleQuote;["];
37+
GenericBlock - [43..49)::6
38+
MarkupTextLiteral - [43..49)::6 - [second] - Gen<Markup>
39+
Text;[second];
40+
MarkupTextLiteral - [49..50)::1 - ["] - Gen<Markup>
41+
DoubleQuote;["];
42+
MarkupMiscAttributeContent - [50..51)::1
43+
MarkupTextLiteral - [50..51)::1 - [ ] - Gen<Markup>
44+
Whitespace;[ ];
45+
ForwardSlash;[/];
46+
CloseAngle;[>];
47+
EndOfFile;[];

0 commit comments

Comments
 (0)